{"slug": "build-a-knowledge-layer-map-your-data-with-an-ontology", "title": "Build a Knowledge Layer: Map Your Data with an Ontology", "summary": "Neo4j published the second post in its five-part \"Build a Knowledge Layer\" series, describing a generic ontology schema that lets AI agents map meaning across multiple enterprise data sources. The schema uses two node types — a DataProduct node representing a whole data source and a SchemaEntity node representing a specific entity such as Customer or LoanFacility — joined by a single generic RELATES relationship that stores the real relationship name as a property. Neo4j illustrates the approach with a fictional bakery loan application that requires four data sources, and released accompanying code in the knowledge-layer-demo repository on GitHub.", "body_md": "# Build a Knowledge Layer: Map Your Data with an Ontology\n\n6 min read\n\n**In this series**\n\n[1. Give Your AI Agents the Shared Context to Succeed](https://neo4j.com/blog/agentic-ai/build-a-knowledge-layer-give-your-ai-agents-the-shared-context-to-succeed/)\n\n**2. Map Your Data with an Ontology**\n\n[3. Turn Your Existing Data into Context](https://neo4j.com/blog/graph-database/build-a-knowledge-layer-turn-your-existing-data-into-context/)\n\n[4. Connect Your Data Sources with a Composite Database](https://neo4j.com/blog/graph-database/build-a-knowledge-layer-connect-your-data-sources-with-a-composite-database/)\n\n[5. Ground Decisions in Precedent](https://neo4j.com/blog/graph-database/build-a-knowledge-layer-ground-decisions-in-precedent/)\n\nCode: [knowledge-layer-demo on GitHub](https://github.com/neo4j-product-examples/knowledge-layer-demo)\n\n### Why does an agent with multiple databases need a map?\n\nUntil now, the readers of enterprise data have been applications and people, and neither needed the data to explain itself. A loan system knows what a Delinquent flag means because that logic is written into its code. A banker knows from years on the job. An AI agent has neither the code nor the years, so the meaning has to come from somewhere else.\n\nLet’s look at Rosa’s Bakery – a fictional business looking to apply for a bank loan.. In order to approve or reject the loan, the agent needs her transactions and KYC status from the banking system, her business plan, the term-loan rules from the lending policy, and earlier loan approval decisions from the decision-history log. That takes four data sources, and nothing tells the agent which one holds what or how they relate. We build each of these sources later in this series.\n\nPutting that knowledge inside the agent means a bigger prompt and a custom tool per source. An ontology graph, which describes the other graphs, holds it instead. This post covers what an ontology holds and how an agent reads it.\n\n### How do you design the schema of an ontology?\n\nAn ontology has to show how data in different systems fits together, and its schema has to stay flexible as the sources change. That’s why the schema is generic. It models how systems relate to each other and how the elements inside each system relate, without hard-coding any one source’s specifics.\n\nIn our example, we kept ours deliberately small, with two node types connected in a few simple ways.\n\nA `DataProduct` node represents a single data source as a whole – for example, the banking system or the raw data ingested by [Document Intelligence](https://neo4j.com/docs/aura/document-intelligence/introduction/). It holds a name, a plain description of what the source contains, a description of what technically backs it, and a color used to visually group it in the UI. \n\nA `SchemaEntity` node represents a real, specific entity within a data source, such as a `Customer` or `LoanFacility`. \n\nOntologies show how things relate without explicitly recreating each source’s named relationships. One generic `RELATES` relationship connects any two entities and stores the real name as a property. \n\nIn the visual below, the Nordtell `DataProduct` links to its `Customer` and `LoanFacility` entities, and `RELATES` connects the two with the name `HAS_FACILITY` as a property on that `RELATES` relationship. \n\n### How do ontologies model how data sources relate to each other?\n\nAn ontology represents each data source as a node and connects those nodes with relationships that describe the role one source plays for another, such as holding the same real-world entity, adding context, setting the rules, or serving as the basis for a decision.\n\nIn our example, the `DataProduct` nodes connect directly to one another inside the ontology, describing how the five sources relate at a high level. The sources themselves are introduced in the next few posts. \n\nModeling these relationships tells the agent how the sources fit together, like the lending policy governing the banking data, so it knows where to look without any integrations between the databases.\n\nThese connections come in four types: `RESOLVES`, meaning the sources on either end hold the same real-world entity; `SUPPLEMENTS`, meaning one source adds extra context to another; `GOVERNS`, meaning one source constrains what’s allowed in another; and `CITES`, meaning one source names another as the basis for a decision. \n\n### How does an agent use an ontology?\n\nAn agent uses an ontology to find out what exists and how it connects before it writes a query, so it doesn’t have to guess or carry that knowledge in its prompt.\n\nThe ontology is exposed to agents through two tools. get_schema_help reads the ontology to show the agent where data lives and what it looks like. ontology_guided_query then uses what the agent learned to run a guarded, read-only query against the right source.\n\nWithout an ontology, the system prompt would then need to carry a lot more information about each source’s labels and relationship types to guide the agent. Depending on the complexity of the underlying sources, that could look something like this (each of these sources is introduced in a later post):\n\n``` php\nMeridian (banking Virtual Graph):\n\n  (Customer)-[:OWNS_ACCOUNT]->(Account)-[:HAS_TRANSACTION]->(Transaction)\n\n  (Customer)-[:HAS_FACILITY]->(LoanFacility)\n\n  (Customer)-[:HAS_KYC_STATUS]->(KYCStatus)\n\n  (Customer)-[:HAS_CREDIT_SCORE]->(CreditScore)\n\n  (Customer)-[:APPLIED_FOR]->(LoanApplication)\n\n  (Customer)-[:MANAGED_BY]->(Employee)-[:WORKS_AT]->(Branch)\n\n  (Customer)-[:HAS_PARENT]->(Customer)\n\nDocuments (business plan graph):\n\n  (Person)-[:WORKED_AT]->(Organization), (Person)-[:CO_OWNS]->(Property)\n\n  (Person)-[:OWNS]->(Organization), (Organization)-[:REQUESTS]->(LoanRequest)\n\nLending policy:\n\n  (PolicyDocument)-[:HAS_SECTION]->(PolicySection)-[:HAS_RULE]->(PolicyRule)\n\n  (PolicyRule)-[:REQUIRES_ESCALATION]->(EscalationPath)\n\n...and the same again for the decision history and the shadow database.\n```\n\nWorse still, every line of that goes stale when a source changes, and it has to be repeated at the prompt of every agent. It also costs tokens on every call, whether or not the question needs it.\n\nThanks to ontologies, our prompt instead carries one instruction. The “constituents” it mentions are the individual graphs that a composite database connects, which a later post covers:\n\n```\nFor anything the tools above don't cover (a question about an entity or relationship\n\nthat isn't exposed by a dedicated tool), use get_schema_help and ontology_guided_query\n\ninstead of declining or guessing. Call get_schema_help first -- with no arguments for\n\nthe five-constituent map, or with a constituent name (e.g. \"meridian\") for its real\n\nlabels and relationship types -- so you know what's actually there before writing a\n\nquery. Never cite or query a label/relationship name you haven't confirmed this way.\n\nThen call ontology_guided_query with that constituent and a read-only MATCH...RETURN\n\nCypher query to actually answer the question.\n```\n\n### How do you create an ontology at scale?\n\nOntologies are hard to build and maintain by hand. Sources change, definitions drift, and the ontology has to keep up with all of it.\n\n[Neo4j Context Engine](https://neo4j.com/blog/news/neo4j-context-engine/), now in private preview, gives you a place to do that work. Its core is a six-layer business ontology that you define and store in Neo4j, with Context Studio to manage and govern it. The layers go beyond our demo’s data products and schemas, to domain terms and business processes.\n\nWith the ontology in place, your agent has a map to read before it queries.\n\n### Next steps\n\n- The previous post, [Give Your AI Agents the Shared Context to Succeed](https://neo4j.com/blog/agentic-ai/build-a-knowledge-layer-give-your-ai-agents-the-shared-context-to-succeed/) , explains why agents need a knowledge layer.\n- Next, [Turn Your Existing Data into Context](https://neo4j.com/blog/graph-database/build-a-knowledge-layer-turn-your-existing-data-into-context/) shows how to build the knowledge graphs this ontology describes.\n- To see where Neo4j is taking the ontology layer, read the [Neo4j Context Engine announcement](https://neo4j.com/blog/news/neo4j-context-engine/) .", "url": "https://wpnews.pro/news/build-a-knowledge-layer-map-your-data-with-an-ontology", "canonical_source": "https://neo4j.com/blog/graph-database/build-a-knowledge-layer-map-your-data-with-an-ontology/", "published_at": "2026-11-10 14:00:00+00:00", "updated_at": "2026-11-24 18:20:44.158232+00:00", "lang": "en", "topics": ["ai-agents", "artificial-intelligence", "ai-tools"], "entities": ["Neo4j", "Rosa's Bakery", "Document Intelligence", "knowledge-layer-demo", "GitHub"], "also_reported_by": [], "takeaway": "Model each data source as a DataProduct node and each entity inside it as a SchemaEntity node, then connect any two entities with one generic RELATES relationship that stores the real name (e.g. HAS_FACILITY) as a property, keeping the ontology schema stable as sources change.", "recommendation": {"advice": "Give agents a separate ontology graph with DataProduct and SchemaEntity nodes and a generic RELATES edge carrying the real relationship name, so multi-source context stays out of the prompt and survives source changes.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/build-a-knowledge-layer-map-your-data-with-an-ontology", "markdown": "https://wpnews.pro/news/build-a-knowledge-layer-map-your-data-with-an-ontology.md", "text": "https://wpnews.pro/news/build-a-knowledge-layer-map-your-data-with-an-ontology.txt", "jsonld": "https://wpnews.pro/news/build-a-knowledge-layer-map-your-data-with-an-ontology.jsonld"}}