An ontology is the formal vocabulary and rule set for a domain (its classes, properties, constraints, and axioms), while a knowledge graph is the body of instance data, the actual entities and relationships, organized according to that vocabulary. The ontology says that a Person can be awarded a Prize; the knowledge graph says that Marie Curie was awarded the Nobel Prize in Physics in 1903. The two are related the way a database schema is related to the rows in its tables, with the difference that a knowledge graph can use one ontology, several at once, or only a loose schema.
The core distinction
The confusion between the two terms comes from the fact that they are usually stored together, often in the same triple store, and expressed in the same syntax. In RDF, an ontology and the data it describes are both sets of triples. The difference lies in what the triples are about.
An ontology contains statements about types and predicates. It says what kinds of things exist in the domain, what relationships can hold between them, and what follows logically from those relationships. Ontology statements are sometimes called terminological knowledge, or the “T-box” in description logic literature.
A knowledge graph contains statements about individuals. It says which specific things exist and how they are connected. These are assertional statements, or the “A-box”. A knowledge graph without any ontology is still a graph of facts, but the facts have no agreed meaning beyond their labels. An ontology without any instance data is a specification that describes nothing in particular.
For a fuller definition of the graph side, see what is a knowledge graph. For a deeper treatment of the schema side, see ontologies.
Comparison table
| Aspect | Ontology | Knowledge graph |
|---|---|---|
| What it describes | Types of things and relationships (classes, properties) | Specific things and their actual relationships (instances) |
| Typical content | Person, Prize, awarded, domain and range rules, class hierarchies | Marie Curie, Nobel Prize in Physics 1903, the awarded edge between them |
| Languages | RDFS, OWL, SKOS (for lighter vocabularies), SHACL (for validation shapes) | RDF triples, labeled property graph (LPG) nodes and edges, JSON-LD documents |
| Size | Usually tens to a few thousand terms | Often millions to billions of statements |
| Rate of change | Slow; changes are design decisions | Continuous; new entities and facts arrive daily |
| Who writes it | Domain experts and ontologists | Extraction pipelines, data integration, human curation |
| Can exist alone | Yes, as a specification (schema.org publishes a vocabulary with no instance data) | Yes, with only implicit or loose typing (many labeled property graphs) |
| Supports reasoning | Defines the inference rules | Is the input over which inference runs |
| Examples | schema.org, FOAF, the Gene Ontology, Wikidata’s property definitions | Wikidata, DBpedia, the Google Knowledge Graph, a company’s product graph |
How they fit together
The relationship is layered. At the bottom is a data model, such as RDF or the labeled property graph (LPG) model, that defines what a statement looks like. On top sits the ontology, which declares which classes and properties are valid in a domain. On top of that sits the knowledge graph proper: instance data typed against those classes and connected by those properties.
An ontology gives a knowledge graph three things. First, shared meaning: two teams that both use schema:Person mean the same thing, so their data can be merged. Second, constraints: a property with a declared range of xsd:date will reject or flag a string like “sometime in 1903”. Third, inference: if Physicist is declared a subclass of Scientist, a reasoner can conclude that every physicist in the graph is a scientist without anyone writing that triple.
Wikidata illustrates the mixed case. Its property definitions and class items (for example, “human”, Q5, and “instance of”, P31) function as an informal ontology, but constraints are advisory rather than enforced, and the community adds classes as needed. It is a knowledge graph with a loose, evolving ontology rather than one designed up front.
Worked example: one ontology, one graph
The following Turtle defines a very small ontology using RDFS and OWL. It declares two classes, one object property, and one datatype property.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <https://example.org/ontology/> .
ex:Person a owl:Class .
ex:Award a owl:Class .
ex:awarded a owl:ObjectProperty ;
rdfs:domain ex:Person ;
rdfs:range ex:Award .
ex:awardYear a owl:DatatypeProperty ;
rdfs:domain ex:Award ;
rdfs:range xsd:gYear .
Nothing in that block mentions a real person. It only says what kinds of statements are allowed. The knowledge graph is the set of triples that use those terms to describe actual entities:
@prefix ex: <https://example.org/ontology/> .
@prefix data: <https://example.org/data/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix wd: <http://www.wikidata.org/entity/> .
data:marie_curie a ex:Person ;
ex:awarded data:nobel_physics_1903 ;
owl:sameAs wd:Q7186 .
data:nobel_physics_1903 a ex:Award ;
ex:awardYear "1903"^^<http://www.w3.org/2001/XMLSchema#gYear> .
The first block is the ontology. The second block is the knowledge graph. The owl:sameAs link to Wikidata item Q7186 connects the local entity to a public identifier for Marie Curie, which is how separate graphs are joined. Because ex:awarded has a declared domain of ex:Person, a reasoner would infer that data:marie_curie is a Person even if the explicit a ex:Person triple were missing. That inference is the ontology doing work over the graph. See triples: subject, predicate, object for how each line above decomposes.
Taxonomy vs ontology
A taxonomy is a simpler artifact than an ontology. It is a hierarchy of categories connected by a single relationship, usually “is a broader category of” or “is a kind of”. A library classification scheme, a product category tree, and a folder structure are taxonomies. An ontology contains a taxonomy (its class hierarchy) but adds named properties between classes, constraints on those properties, and axioms that permit inference. SKOS is the W3C vocabulary designed for publishing taxonomies and thesauri as RDF, and it is often the right choice when a full OWL ontology would be more machinery than the domain needs.
When to use which
The choice is rarely one or the other, since a useful knowledge graph almost always has at least an informal ontology. The practical question is how much ontology to build before loading data.
Build the ontology first, with some care, when several teams or organizations will contribute data and need to agree on meaning, when validation matters (regulatory data, clinical data, financial reporting), or when inference is a requirement rather than a convenience. Reuse existing vocabularies (schema.org, FOAF, Dublin Core, domain ontologies such as SNOMED CT) before inventing new classes.
Start from the data and let a loose schema emerge when the graph is exploratory, when the source is a single system that already has a clear structure, or when the main use is traversal and lookup rather than reasoning. Labeled property graph databases such as Neo4j encourage this style: node labels and relationship types act as a lightweight schema without any formal ontology file. A schema can be formalized later once the shape of the data has settled.
Choose a taxonomy rather than an ontology when the only relationship that matters is hierarchy, as in navigation menus, subject classification, or content tagging.
For developers
Keep the ontology and the instance data in separate named graphs or separate files even when they load into the same store. It makes versioning cleaner, and it allows the same ontology to govern several datasets. Validate instance data against SHACL shapes rather than relying on OWL alone; OWL is designed for inference under the open-world assumption and will not, by itself, report that a required property is missing. See SHACL and OWL for how the two languages divide that work.
For SEOs
schema.org is an ontology (a vocabulary of types and properties), and the JSON-LD on a page is a fragment of knowledge graph that uses it. Marking up an organization with @type: Organization and a sameAs array pointing to its Wikidata and Wikipedia pages supplies instance data that Google can reconcile against entities it already knows. The ontology half is fixed by schema.org; the SEO’s job is the instance half, and the payoff is in the consistency and disambiguation of those instances. See schema.org and sameAs schema.
Common misconceptions
Treating the terms as synonyms is the most common error, and it usually surfaces when someone asks for “an ontology” and wants a populated graph, or the reverse. A second misconception is that a knowledge graph requires a formal OWL ontology; many production graphs, including most built on LPG databases, run on labels and conventions alone. A third is that an ontology is a taxonomy with a more formal name. The class hierarchy is one part; the properties, constraints, and axioms make it more than a category tree. Finally, “ontology” here does not carry its philosophical meaning. In information science it is an engineered artifact, a specification of a conceptualization.
Related pages
- What is a knowledge graph
- Ontologies
- Triples: subject, predicate, object
- Knowledge graph vs graph database
- OWL
- schema.org
FAQ
Is an ontology a knowledge graph?
No. An ontology defines the classes, properties, and rules that a knowledge graph uses, but it does not contain the entities themselves. schema.org, for example, is an ontology that defines the type Person and the property birthDate, yet it says nothing about any particular person. A knowledge graph is the instance data that applies those definitions to real things.
Can a knowledge graph exist without an ontology?
Yes, in the sense that a graph of typed nodes and edges can be built and queried with no formal ontology file. Most labeled property graphs work this way, using node labels and relationship types as an informal schema. Without an ontology, though, the graph has no machine-readable definition of what its labels mean, which limits data integration and rules out automated inference.
What is the difference between a taxonomy and an ontology?
A taxonomy is a hierarchy built from a single relationship, such as “is a subcategory of”. An ontology includes a class hierarchy but adds named properties between classes (a Person is awarded a Prize), constraints on those properties (the award year must be a year), and axioms that allow a reasoner to infer new facts. SKOS is the usual RDF vocabulary for taxonomies; OWL is used for ontologies.
Is schema.org an ontology or a knowledge graph?
schema.org is an ontology, or more precisely a shared vocabulary of types and properties expressed in RDFS-style terms. The JSON-LD, Microdata, or RDFa that a website publishes using schema.org types is instance data, which means each marked-up page contributes a small fragment of knowledge graph. Google and other consumers merge those fragments with their own graphs.
Sources and further reading
- W3C, OWL 2 Web Ontology Language Primer: https://www.w3.org/TR/owl2-primer/
- W3C, RDF Schema 1.1: https://www.w3.org/TR/rdf-schema/
- W3C, SKOS Simple Knowledge Organization System Primer: https://www.w3.org/TR/skos-primer/
- Hogan et al., Knowledge Graphs (book and online text): https://kgbook.org/
- schema.org documentation: https://schema.org/docs/documents.html
- Wikidata, Marie Curie (Q7186): https://www.wikidata.org/wiki/Q7186
