Why Ontology Should Be Treated as Code
The Core Argument
Tony Seale's central thesis: ontologies are logic, not data storage. They declare what kinds of things exist, how they relate, and what cannot both be true. Treating them as code enables compilation, validation, versioning, and review — capabilities that database tables cannot provide for logical artifacts.
Three Pillars of Ontology as Code
Ontology Should Compile
An ontology should compile — not just parse. The syntax should be valid, classes satisfiable, and entailments expected. An absent entailment is a test failure. If the model says two things that cannot both be true, the build should break.
CompilationOntology Should Live in Plain Text
Ontologies should live in plain text files — enabling diffs, branches, blame, pull requests, and review in context. LLMs should read, navigate, and edit the source directly, exactly the way they work with a codebase.
Version ControlOntology Should Be Governed Like Code
Ontologies should use branches, pull requests, reviews, automated checks, releases, and builds. The artefact that decides what an organisation means by a customer, an order, a risk, or a product should not be governed less rigorously than the CSS on a marketing site.
GovernanceFrequently Asked Questions
Ontologies declare what kinds of things exist, how they relate, and what cannot both be true. They are formal logic expressed as rigorous axioms. Treating them as code enables compilation, validation, versioning, and review — capabilities that database tables cannot provide for logical artifacts.
An ontology should compile meaning its syntax should be valid, classes should be satisfiable, and entailments should be the ones expected. An absent entailment is a test failure, not a curiosity discovered months later in production. If the model says two things that cannot both be true, the build should break.
Plain text files enable diffs, branches, blame line by line, pull requests, and review in context. This is especially important now that LLMs are in the loop — you want the LLM reading, navigating, and editing the source directly, exactly the way it works with a codebase.
Ontologies should use branches, pull requests, reviews, automated checks, releases, and builds. The artefact that decides what an organisation means by a customer, an order, a risk, or a product should not be governed less rigorously than the CSS on a marketing site.
LLMs can express conceptualizations in any RDF notation (Turtle, JSON-LD, RDF/XML) and save the result to a file. LLM-powered agents loosely coupled with appropriate skills make the process dramatically easier. You can copy files to a folder transparently bound to a backend RDF DBMS for updating the quad/triple store.
An operational ontology describes objects, attributes, and relationships — what exists. A decision ontology describes who owns each decision, what triggers it, what action it generates, and how the loop closes. An operational ontology makes data legible; a decision ontology makes the enterprise executable.
If your ontology currently lives in database tables or spreadsheets, extract it using a simple script. Four lines of Python can convert table rows to RDF triples in Turtle or JSON-LD format, enabling version control, diffs, and all the benefits of code-based ontology management.
For Linked Art, part of the compile pipeline processes the ontology from RDFS+OWL into a Python class library. Instead of manually adding triples to a graph, engineers can use familiar object-oriented patterns: r = Person(id='Rob'); r.name = 'Rob'. The ontology transpiles to developer-friendly code.
An ontology is fundamentally a (hyper-)graph of interrelated concepts. Code is typically a tree structure. The argument for treating ontology as code is about the management practices — versioning, review, compilation — not about the underlying data structure being a tree.
As AI systems increasingly consume organizational context as a direct input, the ontology stops being documentation and starts being an active dependency. Who owns it and how well they guard it becomes one of the more consequential product decisions a company will make.
RDF-Turtle is very human-readable shorthand but historically lacked tooling support. JSON-LD had more tooling support but wasn't as human-readable. RDF/XML was challenged on both fronts. Today, LLMs bridge this gap by generating any notation on demand.
A common journey: start with an idea in your head, then a note in a notebook, then an Excel table, then a SQL table (or set of them), and finally a graph database. Each step represents increasing sophistication in modeling relationships and semantics.
Key Terms
How to Treat Your Ontology as Code
Extract Your Ontology from Tables
If your ontology currently lives in database tables or spreadsheets, extract it using a simple script. Four lines of Python can convert table rows to RDF triples in Turtle or JSON-LD format.
Save to Plain Text Files
Save your ontology as plain text files in a version control system (Git). Use Turtle for human readability or JSON-LD for tooling compatibility. Organize by domain or module.
Set Up Compilation Pipeline
Configure a build pipeline that validates syntax, checks class satisfiability, and verifies expected entailments. Use tools like PySHACL, Jena, or Protégé for validation. The build should break on contradictions.
Establish Code Review Process
Require pull requests for all ontology changes. Review in context with diffs. Ensure new terms don't silently duplicate existing concepts. Treat ontology review with the same rigor as application code review.
Integrate LLM Agents
Configure LLM-powered agents to read, navigate, and edit your ontology source files directly. Use skills to express conceptualizations in any RDF notation on demand. Connect to a backend RDF DBMS for quad store updates.
Define Decision Ontology
Beyond operational ontology (what exists), define a decision ontology: who owns each decision, what triggers it, what action it generates, and how the loop closes. This makes your enterprise executable.
Ship Releases
Version your ontology releases like software releases. Tag versions, maintain changelogs, and ensure downstream systems consume specific versions. The ontology that defines organizational meaning should be shipped with the same rigor as application code.
Explore the Knowledge Graph
List All Comments and Authors
PREFIX schema: <http://schema.org/> SELECT ?comment ?author ?text WHERE { GRAPH <https://linkeddata.uriburner.com/DAV/demos/daas/ontology-is-code-tony-seale-linkedin-post-qwen3.6-plus-free-1.ttl> { ?comment a schema:Comment ; schema:author ?author ; schema:text ?text . } } ORDER BY ?author
Describe the Main Post and Its Author
PREFIX schema: <http://schema.org/> DESCRIBE <https://www.linkedin.com/posts/tonyseale_did-you-start-building-your-ontology-as-a-share-7463353332565356545-jY54/#> <https://www.linkedin.com/posts/tonyseale_did-you-start-building-your-ontology-as-a-share-7463353332565356545-jY54/#tonySeale>
Construct the FAQ Subgraph
PREFIX schema: <http://schema.org/> CONSTRUCT { ?q a schema:Question ; schema:name ?name ; schema:acceptedAnswer ?a . ?a a schema:Answer ; schema:text ?text . } FROM <https://linkeddata.uriburner.com/DAV/demos/daas/ontology-is-code-tony-seale-linkedin-post-qwen3.6-plus-free-1.ttl> WHERE { ?q a schema:Question ; schema:name ?name ; schema:acceptedAnswer ?a . ?a schema:text ?text . }
KG Explorer
RDF Graph Workbench
0 nodes / 0 linksExplore Knowledge Graph using SPARQL
format=text/x-html+tr. DESCRIBE/CONSTRUCT queries use format=text/x-html-nice-turtle.
Comments from Knowledge Graph Practitioners