Project:Sample queries
From MaRDI portal
Generic Examples
Select All Triples
SELECT * WHERE { ?a ?b ?c }
Select All Triples relating to Q1
SELECT * WHERE { wd:Q1 ?b ?c }
MathModDB Examples
Find all roles of expressions sorted by usage frequency
SELECT ?rolesEquationLabel ?rolesEquationDescription (COUNT(*) AS ?count) ?rolesEquation
WHERE {
?URL wdt:P1495 wd:Q6534265 .
?URL ?p ?statement .
FILTER(STRSTARTS(STR(?p), "https://portal.mardi4nfdi.de/prop/")) # keep statement nodes
# Main value of the statement (ps:)
?statement ?ps ?mainValue .
FILTER(STRSTARTS(STR(?ps), STR(ps:)))
# Get the instance-of class of the value
?mainValue wdt:P31 ?valueClass .
# Keep only values whose class is exactly Q6481152
FILTER(?valueClass = <https://portal.mardi4nfdi.de/entity/Q6481152>)
# Qualifier values (pq:)
?statement ?pq ?rolesEquation .
FILTER(STRSTARTS(STR(?pq), STR(pq:)))
# Map qualifier IRI to property entity
BIND(IRI(REPLACE(STR(?pq),
"https://portal.mardi4nfdi.de/prop/qualifier/",
"https://portal.mardi4nfdi.de/entity/")) AS ?qualifier)
# Keep only qualifier that refer to object has role P560
FILTER(?qualifier = <https://portal.mardi4nfdi.de/entity/P560>)
# Get labels for all entities
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?rolesEquationLabel ?rolesEquationDescription ?rolesEquation
ORDER BY DESC(?count)
Find all discrete-time expressions
SELECT DISTINCT ?expressionLabel ?expressionDescription ?expression
WHERE {
?expression wdt:P1495 wd:Q6534265 ;
wdt:P31 ?instanceOf .
VALUES ?instanceOf { wd:Q6672095 wd:Q6672094 wd:Q6775547 wd:Q6775548 wd:Q6775549 }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?expressionLabel
Find all models containing at least one ODE (ordinary differential equation)
SELECT DISTINCT ?itemLabel ?item
WHERE {
# item belongs to community MathModDB
# and item is instance of a mathematical model
?item wdt:P1495 wd:Q6534265 ;
wdt:P31 wd:Q68663 .
# all P1560 statements
?item wdt:P1560 ?containedItem .
# instance of ordinary differential equation
?containedItem wdt:P31 wd:Q6481447 .
OPTIONAL {
?item rdfs:label ?itemLabel .
FILTER (LANG(?itemLabel) = "en")
}
}
ORDER BY ?itemLabel
Find all items with QUDT quantity kind ID
SELECT DISTINCT ?itemLabel ?item ?itemDescription ?QUDTid
WHERE {
?item wdt:P1495 wd:Q6534265 ;
wdt:P1654 ?QUDTOnlyid .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
BIND(IRI(CONCAT("https://qudt.org/vocab/quantitykind/", ?QUDTOnlyid)) AS ?QUDTid)
}
ORDER BY ?itemLabel