RDF & SPARQL
The data model and DSL that RARS is built on.
If you've looked at a .ttl file and wondered what all the colons, angle brackets, and semicolons mean, you're in the right place.
Matrices are written using two standards: RDF and SPARQL. RDF is a way to describe data. SPARQL is a way to work with it. This section teaches both from scratch, assuming you've never seen either.
What Is RDF
RDF (Resource Description Framework) is a data model. It represents everything as simple three-part statements: a subject, a predicate, and an object. These statements are called triples.
A triple is one fact:
Alice knows BobThat's it. Alice is the subject. "knows" is the predicate. Bob is the object. Your data is a collection of these facts, forming a graph of interconnected things.
If you've worked with JSON, SQL, or any other data format, the concepts map directly:
| You're used to | RDF equivalent |
|---|---|
| An object or a row | A resource (identified by a URI) |
| A key-value pair or column | A triple (subject-predicate-object) |
| A table name or type field | A type statement (rdf:type) |
| A foreign key or nested object | A triple where the object is another resource |
| A constraint or validation rule | A SHACL shape |
What Is SPARQL
SPARQL is a DSL for working with RDF data. You describe the pattern of triples you're looking for, and it finds everything that matches:
PREFIX vocab: <https://example.org/vocab/>
PREFIX people: <https://example.org/people/>
SELECT ?person ?name WHERE {
?person vocab:knows people:alice .
?person vocab:name ?name .
}This says: find every person who knows Alice, and get their name. Variables start with ?. Predicates and values use prefixed URIs. The engine matches the patterns against the graph and returns results.
Poliglot extends SPARQL with additional capabilities that turns it into a gateway for AI to manipulate your business systems. Those are covered in the SPARQL pages.
How to Read This Section
Start with RDF. The RDF pages teach the data model: triples, identifiers, types, and the Turtle syntax used in .ttl files.
Then SPARQL. The SPARQL pages teach how to read, write, and transform data in the graph.
Then the supporting concepts:
- Named Graphs: isolated subgraphs and how they're used
- SHACL: the constraint language for data validation