Theory
A mature KG typically has two logical layers that coexist in the same graph but serve different purposes:
| Layer | Example triple | Purpose |
|---|---|---|
| Instance | :Alice :knows :Bob | Records ground facts (what is true) |
| Ontology | :knows rdfs:domain :Person | Defines meaning and constraints |
| Ontology | :Person rdfs:subClassOf :Agent | Relates classes for reasoning |
By storing them in separate named graphs (or using naming conventions), you gain:
- Independent versioning: evolve the ontology without touching instance data, and vice‑versa.
- Reasoning: use the ontology to infer new instance triples (e.g., from
:Alice rdf:type :Employeeand:Employee subClassOf :Personinfer:Alice rdf:type :Person). - Reusability: share the same ontology across multiple instance graphs (e.g., in different departments).
A common anti‑pattern is to conflate the two: e.g., storing class hierarchies as application‑specific strings inside instance nodes. This breaks the uniform triple model and prevents generic reasoning tools from working.
