Book a free call

How Is a Knowledge Graph Put Together?

A knowledge graph is built in layers: a store holds the facts, a schema defines what fits, ingestion links the data, and a query layer serves answers.

Hertiv engineering teamReviewed by a senior engineer
8 min read
How Is a Knowledge Graph Put Together?
On this page

Short answer

A knowledge graph architecture is the layered design of a system that stores facts as connected entities: a storage layer holds triples, a schema layer defines the entity and relationship types, an ingestion layer extracts and links data from source systems, and a query layer answers questions by following the connections. Each layer can change without rebuilding the others.

What is a knowledge graph architecture?

A knowledge graph architecture is the layered design of a system that stores facts as connected entities: a storage layer holds triples, a schema layer defines the entity and relationship types, an ingestion layer extracts and links data from source systems, and a query layer answers questions by following the connections.

The layers matter because each one changes on its own schedule. The storage engine can change without rewriting the queries, the schema can gain a new entity type without reloading the data, and the query layer can add a new search page without touching ingestion. Keeping the layers separate is what lets a graph grow from a pilot to a system the business relies on.

The five layers are:

  • Storage. Where triples and their indexes live.
  • Schema. The allowed entity types, relationships and rules.
  • Ingestion. How data is extracted, cleaned and linked.
  • Query and reasoning. How questions are answered and new facts are inferred.
  • Serving. How applications, search and AI tools reach the graph.

A graph is useful when the same fact appears in several systems under different names, and when the relationships between facts matter as much as the facts themselves. The guide to knowledge graphs explains the basic idea; this article covers how the parts fit together.

How does the storage layer work?

The storage layer holds every triple, a subject, a relationship and an object, plus the indexes that make lookups fast. The choice of store decides how the graph scales, how it is queried and how much work the team takes on.

StoreHow it worksBest for
Triple storeBuilt for triples, queried with SPARQLOpen schemas and many sources
Property graphProperties on nodes and edges, queried with Cypher or GremlinFast traversals and rich properties
Relational link tableLinks stored as rows in a normal databaseSmall graphs and a cheap start

A triple store is built for triples and the query language SPARQL. It suits graphs where the schema is open and the data comes from many sources. A property graph store keeps properties on nodes and edges and is queried with Cypher or Gremlin. It suits graphs where the team wants fast traversals and rich properties on each connection.

A small graph can live in a relational database with a link table, which is the cheapest way to start and the easiest to back up. The cost appears as the graph grows: joins across link tables get slower and the queries get harder to read. Choose the store after the model is drawn, not before, because the model and the questions decide the tool.

How does the schema layer shape the graph?

The schema layer, often called the ontology, defines the entity types, the relationships between them and the rules that keep the graph consistent. It is the contract that every ingestion job and every query relies on.

Keep the schema small enough that a new team member can read it in one sitting. Start with no more than eight entity types and twelve relationship types, and give every relationship a clear name and a direction: a customer places an order, an order contains a product, a product is supplied by a supplier. Reuse names the business already uses, so two teams do not invent two names for the same thing.

Version the schema like code. When a new entity type or relationship is needed, add it in a reviewed change with a note about which questions it serves. A schema that changes without a record will split facts across two nodes and give wrong answers, and the team will not know when it started.

How does data get into the graph?

Data reaches the graph through an ingestion layer that extracts records from source systems, cleans them, matches them to existing entities and loads the resulting triples. Ingestion is a pipeline, not a one-off import, because the sources change every day.

Record linkage is usually the hardest part. Two systems often spell the same supplier differently, or use different codes for the same product. Solve this with a matching rule and a review list for the cases the rule cannot decide, rather than hoping the data is already clean. Give every entity a source system and a refresh rule, so users can judge whether to trust what they read.

Record where each fact came from. Provenance, the source, the load date and the matching rule used, is what lets an owner fix a wrong answer by tracing it back to the record it came from. The implementation guide for knowledge graphs covers the build steps in detail.

How do you query and reason over the graph?

The query layer answers questions by following edges from one node to the next. A graph query language such as SPARQL or Cypher expresses a path through the graph, for example which suppliers delivered late to the warehouses that serve your largest customers, and returns the matching nodes with their links.

Reasoning adds facts the graph does not store directly. If the schema says a supplier is late when a delivery misses its date, the query layer can infer that status instead of waiting for someone to record it. Keep inferred facts separate from stored facts, so a wrong rule does not corrupt the data, and record which rule produced each inferred fact.

Test queries against the questions the graph must answer. Write down five questions before you model anything, and check each one against the schema. If a question needs a fact the model cannot hold, add the missing entity or relationship; if part of the model serves no question, cut it.

How does the graph serve applications?

The serving layer is how applications reach the graph: a search page, an API, or a retrieval step inside an AI assistant. A graph with no query path is a database nobody opens, so the first answers should ship with the first load.

For search and recommendations, the serving layer runs the same queries users would run by hand, but behind a page or an endpoint. For AI assistants, the graph supplies the facts the model cites, which is the pattern behind graph-based retrieval: the assistant reads the graph, finds the connected facts and quotes them with links to the source records. The guide to knowledge graphs in machine learning explains how the graph feeds models and retrieval.

Keep the serving layer read-only where possible. Writes go through ingestion, with its matching rules and provenance, so the graph stays consistent. A serving layer that writes directly will create facts no owner can trace.

How do you design a knowledge graph architecture in 6 steps?

You design a knowledge graph architecture by working from the questions down: the questions decide the schema, the schema decides the store, and the store decides the ingestion and serving layers.

  1. Write the questions. List the five questions the graph must answer before you model anything.
  2. Draw the schema. Name the entity types, relationships and key properties on one page, with no more than eight entity types.
  3. Pick the store. Choose a triple store, a property graph or a relational link table, based on size, query style and team skill.
  4. Plan ingestion. List the source systems, pick one source of truth per fact, and write the matching rules for duplicate names.
  5. Build the query layer. Write the queries for the five questions and the inference rules the schema needs.
  6. Ship the serving layer. Put the answers behind a search page or an API, and assign an owner for each entity type.

Review the design with the five questions after each step. If a step adds a part that serves no question, cut it; if a question still has no path, add the missing piece before moving on. The knowledge graph best practices cover the habits that keep the graph accurate.

Example (hypothetical): a retailer maps products to suppliers

Example (hypothetical): a retailer sells 600 products, and each product links to 4 parts on average, which is 2,400 part links. A buyer checking which suppliers can cover a part spends about 8 minutes per check searching catalogues and emails, and makes about 50 checks a week, which is 400 minutes, or about 6 hours and 40 minutes a week.

The team builds a graph with products, parts, suppliers and deliveries, and a search page that answers the check in about 1 minute. Fifty checks a week now take 50 minutes, so the saving is 400 minus 50, or 350 minutes, about 5 hours and 50 minutes a week. The buyer uses part of that time to review the unmatched-record list each week, so the graph keeps improving instead of going stale.

The graph runs on a property graph store, because the team queries paths from product to part to supplier. The schema has six entity types and nine relationship types, and every fact records its source catalogue and load date, so a wrong answer can be traced back to the record it came from.

What are the common mistakes?

The most common knowledge graph architecture mistakes are modelling too much, choosing the store first, and shipping a graph nobody can query.

  • Modelling the whole business. A model with dozens of entity types takes months to build and is hard to explain. Start with one domain and five questions.
  • Choosing the store before the schema. The model and the questions decide the tool, not the other way round.
  • No query path. A graph with no search page or API is a database nobody opens. Ship the first answers with the first load.
  • Skipping record linkage. Duplicate names and different codes are normal. Plan time for matching and cleaning.
  • No owner. Without someone responsible for quality, the graph fills with stale facts and users stop trusting it.
  • Writing through the serving layer. Direct writes bypass matching rules and provenance, so facts appear that no owner can trace.
  • Treating inferred facts as stored facts. A wrong inference rule should be fixable without reloading the data.

Key takeaways

  • A knowledge graph has five layers: storage, schema, ingestion, query and serving
  • Choose the store after the schema: triple store, property graph or relational link table
  • Record linkage is the hardest part, so plan matching rules and a review list
  • Keep inferred facts separate from stored facts, with the rule recorded
  • Ship the first answers with the first load, and give each entity type an owner

Frequently asked questions

What is the difference between a triple store and a property graph?

A triple store holds facts as subject, relationship and object triples and is queried with SPARQL, which suits open schemas and many sources. A property graph keeps properties on nodes and edges and is queried with Cypher or Gremlin, which suits fast traversals and rich properties on each connection.

Do I need a dedicated graph database?

Not at first. A small graph can live in a relational database with a link table, which is cheap to start and easy to back up. As the graph grows, joins across link tables get slower and the queries get harder to read, and that is when a dedicated triple store or property graph earns its place.

What is an ontology in a knowledge graph?

An ontology is the schema layer of the graph: the list of allowed entity types, the relationships between them and the rules that keep the graph consistent. It is the contract that ingestion jobs and queries rely on. Keep it small, version it like code, and change it only through a reviewed update.

How does a knowledge graph help AI assistants?

The graph supplies the facts the assistant cites. Instead of answering from training data alone, the assistant reads the graph, follows the connections to the relevant facts and quotes them with links to the source records. That grounds the answer in data the team controls, which cuts wrong answers.

How do you keep a knowledge graph accurate?

Treat updates as a pipeline, not a one-off project. Give every entity a source system and a refresh rule, assign an owner for each entity type, and track quality each week: entities with no source, relationships that point to missing nodes, and answers users report as wrong.

How long does it take to build a knowledge graph architecture?

A first version for one domain often takes a few weeks: a week to write the questions and draw the schema, a week to build ingestion and linking, and a week to ship the first queries and a search page. The graph then grows one domain at a time, with each new domain reusing the same layers.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning a knowledge graph for search or RAG? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Data Engineering service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call