Added SparQL
This commit is contained in:
parent
12bd781fd3
commit
2487d44abd
67
docs/SPARQL.md
Normal file
67
docs/SPARQL.md
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# SparQL
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Resources taken from [this website](https://sparql.dev/)
|
||||||
|
|
||||||
|
## SQL Queries
|
||||||
|
|
||||||
|
### SELECT
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
SELECT ?var1, ?var2, ...
|
||||||
|
```
|
||||||
|
|
||||||
|
### WHERE
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
WHERE {
|
||||||
|
pattern1 .
|
||||||
|
pattern2 .
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### FILTER
|
||||||
|
|
||||||
|
It's used to restrict [`WHERE`](#where) clauses
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
WHERE {
|
||||||
|
?person <http://example.com/hasCar> ?car .
|
||||||
|
FILTER (?car = <http://example.com/Car1>)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### OPTIONAL
|
||||||
|
|
||||||
|
It's used to fetch available content if exists
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
SELECT ?person ?car
|
||||||
|
WHERE {
|
||||||
|
?person <http://example.com/hasCar> ?car .
|
||||||
|
OPTIONAL {
|
||||||
|
?car <http://example.com/hasColor> ?color .
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### LIMIT
|
||||||
|
|
||||||
|
Limits results
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
LIMIT 10 -- Take only 10 results
|
||||||
|
```
|
||||||
|
|
||||||
|
## SparQL functions
|
||||||
|
|
||||||
|
### COUNT
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
SELECT (COUNT(?person) AS ?count)
|
||||||
|
WHERE {
|
||||||
|
?person <http://example.com/hasCar> ?car .
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user