Web Fundamentals course 2021, 22 April 2021
SELECT: selecting values in tabular form → focus of this presentationCONSTRUCT: construct new triplesASK: check if data existsDESCRIBE: describe a given resourceINSERT: insert new triplesDELETE: delete existing triplesSELECT ?name ?deathDate WHERE {
?person a dbpedia-owl:Artist;
rdfs:label ?name;
dbpedia-owl:birthPlace [ rdfs:label "York"@en ].
FILTER LANGMATCHES(LANG(?name), "EN")
OPTIONAL { ?person dbpprop:dateOfDeath ?deathDate. }
}
| name | deathDate |
| Albert Joseph Moore | |
| Charles Francis Hansom | 1888 |
| David Reed (comedian) | |
| Dustin Gee | |
| E Ridsdale Tate | 1922 |
RDF dataset + SPARQL query
↓
...
↓
query results
RDF dataset + SPARQL query
↓
SPARQL query processing
↓
query results
?person a dbpedia-owl:Artist.
?person rdfs:label ?name.
?person dbpedia-owl:birthPlace ?birthPlace.
?, followed by a label. (e.g. ?name)
OPTIONAL, UNION, FILTER, ...
| name | birthplace |
| Bob Brockmann | http://dbpedia.org/resource/Louisiana |
| Bennie Nawahi | http://dbpedia.org/resource/Honolulu |
| Weird Al Yankovic | http://dbpedia.org/resource/Downey,_California |
SELECT ?x ?y ?z WHERE {
?x ?y ?z
}
{
"type": "project",
"input": {
"type": "bgp",
"patterns": [
{
"type": "pattern",
"subject": {
"termType": "Variable",
"value": "x"
},
"predicate": {
"termType": "Variable",
"value": "y"
},
"object": {
"termType": "Variable",
"value": "z"
}
}
]
},
"variables": [
{ "termType": "Variable",
"value": "x" },
{ "termType": "Variable",
"value": "y" },
{ "termType": "Variable",
"value": "z" }
]
}
ORDER BY + DISTINCTORDER BY: Sort solution mappings by the given variable
DISTINCT: Remove duplicate solution mappings
DISTINCT to happen after ORDER BY
DISTINCT before ORDER BY
{
"type": "distinct",
"input": {
"type": "orderby",
"variable": "x",
"input": { ... }
}
}
{
"type": "orderby",
"variable": "x",
"input": {
"type": "distinct",
"input": { ... }
}
}
1. ?person a dbpedia-owl:Artist.
2. ?person rdfs:label ?name.
3. ?person dbpedia-owl:birthPlace ?birthPlace.
1. ?person a dbpedia-owl:Artist.
200
2. ?person rdfs:label ?name.
10.000
3. ?person dbpedia-owl:birthPlace ?birthPlace.
1.000
n, m)
O(n*m)O(n+m)OPTIONAL
O(n+m)((1 ⋈ 2) ⋈ 3) = ((200 * 10.000) * 1.000) = 2.000.000.000
((1 ⋈ 2) ⋈ 3) = ((200 + 10.000) + 1.000) = 11.200
((1 ⋈ 3) ⋈ 2) = ((200 * 1.000) + 10.000) = 210.000
→ Restrictions and preprocessing steps (sorting, hashing, ...) not yet taken into account
→ Trade-off between different factors that influence join order
Based on operator type
{
"type": "project",
"variables": [ ... ]
"input": {
"type": "bgp",
"patterns": [
{
"type": "pattern",
"subject": { ... },
"predicate": { ... },
"object": { ... }
},
{
"type": "pattern",
"subject": { ... },
"predicate": { ... },
"object": { ... }
}
]
}
}
{
"type": "project",
"variables": [ ... ]
"input": {
"type": "bgp",
"patterns": [
{
"type": "pattern",
"subject": { ... },
"predicate": { ... },
"object": { ... }
},
{
"type": "pattern",
"subject": { ... },
"predicate": { ... },
"object": { ... }
}
]
}
}
{
"type": "project",
"variables": [ ... ]
"input": {
"type": "bgp",
"patterns": [
{
...solution sequence...
},
{
"type": "pattern",
"subject": { ... },
"predicate": { ... },
"object": { ... }
}
]
}
}
{
"type": "project",
"variables": [ ... ]
"input": {
"type": "bgp",
"patterns": [
{
...solution sequence...
},
{
"type": "pattern",
"subject": { ... },
"predicate": { ... },
"object": { ... }
}
]
}
}
{
"type": "project",
"variables": [ ... ]
"input": {
"type": "bgp",
"patterns": [
{
...solution sequence...
},
{
...solution sequence...
}
]
}
}
{
"type": "project",
"variables": [ ... ]
"input": {
"type": "bgp",
"patterns": [
{
...solution sequence...
},
{
...solution sequence...
}
]
} }
{
"type": "project",
"variables": [ ... ]
"input": {
...solution sequence...
} }
{
"type": "project",
"variables": [ ... ]
"input": {
...solution sequence...
}
}
...solution sequence...