On this page
- What is a knowledge graph made of?
- Where did the term "knowledge graph" come from?
- RDF vs property graph: what is the difference?
- What are some examples of knowledge graphs?
- How do you query a knowledge graph?
- How is a knowledge graph built?
- How do knowledge graphs work with LLMs and GraphRAG?
- Can a knowledge graph work as memory for AI agents?
- Knowledge graph vs vector database vs relational database: which fits?
- When do you not need a knowledge graph?
- Which tools can you use to build a knowledge graph?
- Sources
A knowledge graph is a way of storing facts as a network: things such as people, products, services or places become nodes, and the relationships between them become labeled, directed edges. A schema or ontology on top defines which kinds of things exist and what each relationship means, so people and software read the data the same way.
That schema layer separates a knowledge graph from any drawing of dots and lines. This guide covers the two main data models, real examples, how graphs get built, queries you can run, and where graphs fit next to LLMs, relational databases and vector databases.
What is a knowledge graph made of?
Every knowledge graph has three layers:
- Entities (nodes). Each node stands for one thing: a person, a company, a library, a support ticket. It needs a stable identifier, so that Paris in France and Paris in Texas never merge.
- Relationships (edges). An edge connects two nodes and carries a label that says how they relate, such as
MAINTAINS,DEPENDS_ONor "born in". Edges have a direction: a service depends on a library, not the other way round. - Schema or ontology. This layer names the entity types (Person, Service, Library) and the relationships allowed between them. In the RDF world it is an ontology written in a standard language; in property graph databases it is usually lighter: labels, relationship types and constraints.
Attributes can also hang off nodes and edges, such as a release date or the version of a library a service uses.

The diagram shows the example used throughout this guide: a schema row on top, and data that follows it below. Even with five nodes, the graph answers a practical question: if auth-lib gets a security advisory, which services are affected and who needs to know?
A knowledge graph is a data model plus meaning, not a product. You can keep one in a graph database, an RDF triplestore, PostgreSQL tables or, like one popular AI memory server, a JSON Lines file.
Where did the term "knowledge graph" come from?
The ideas are older than the name: the W3C published the first Resource Description Framework (RDF) specification as a Recommendation on 22 February 1999 (W3C).
The term went mainstream on May 16, 2012, when Google's Amit Singhal announced the Knowledge Graph in a post titled "Introducing the Knowledge Graph: things, not strings". Google said the graph already held more than 500 million objects and more than 3.5 billion facts about and relationships between them, and that it helped Search tell apart queries such as the Taj Mahal monument and the musician of the same name (Google). "Things, not strings" is still the shortest summary of the idea.
RDF vs property graph: what is the difference?
Two data models dominate. Both store nodes and edges, but they make different trade-offs.
RDF: triples, IRIs and ontologies
In RDF, every fact is a triple of subject, predicate and object, and a set of triples forms an RDF graph (W3C RDF 1.1 Concepts). Subjects and predicates are IRIs, web-style identifiers such as https://example.com/kg/auth-lib, and objects are IRIs or literal values such as strings and dates. Because identifiers are global, datasets that use the same IRI for the same thing merge without a mapping step.
The schema layer uses standard vocabularies. RDF Schema (RDFS) declares classes and properties, and the Web Ontology Language, OWL 2, adds richer constructs such as equivalent classes, cardinality restrictions and property characteristics (W3C OWL 2 Overview). Both are built for inference: a reasoner derives new facts from stored ones. Validating data against rules is the job of a separate standard, SHACL (W3C SHACL). The query language is SPARQL, whose 1.1 version has been a W3C Recommendation since March 2013 (W3C SPARQL 1.1).
RDF 1.2, a Candidate Recommendation Draft as of November 2026, adds triple terms, which let one triple appear as the object of another, so you can make statements about statements (W3C RDF 1.2 Concepts).
Labeled property graphs: nodes, relationships and properties
A labeled property graph stores nodes with one or more labels (Person, Service) and relationships with a type (DEPENDS_ON). Both nodes and relationships carry key-value properties, so "payments-api depends on auth-lib, version 2.1" is one edge with one property. Neo4j and Memgraph are two widely used databases of this kind, and both use Cypher.
Property graphs now have an international standard of their own. ISO/IEC 39075:2024, Information technology, Database languages, GQL, was published by ISO in April 2024 (ISO). Neo4j's documentation says GQL adopted much of Cypher's query construction, including the MATCH/RETURN format, and that Cypher supports most mandatory GQL features, with a few still missing (Neo4j Cypher Manual).
How to choose between them
- Pick RDF When data has to be shared or merged across organizations, when you want to reuse public vocabularies such as Wikidata or schema.org, or when you need standard inference and portable W3C formats.
- Pick a property graph When the graph serves one application, when edges need attributes such as weights, timestamps or versions, and when developers will write traversal queries every day. Cypher patterns look like the diagram you would draw on a whiteboard.
What are some examples of knowledge graphs?
Wikidata is an open knowledge graph anyone can edit. It stores items, identified by a Q followed by a number, and properties, identified by a P. Douglas Adams is Q42, and the statement "educated at" (P69) links him to St John's College (Q691283). Its structured data is released under the CC0 public domain dedication (Wikidata). In November 2026 Wikidata reported more than 124 million items, and anyone can query it with SPARQL at query.wikidata.org.
Schema.org markup is the knowledge graph most web developers have already written. Schema.org is a shared vocabulary founded by Google, Microsoft, Yahoo and Yandex (Schema.org). Google uses this structured data to understand page content and recommends the JSON-LD format (Google Search Central), and JSON-LD is itself an RDF syntax. iThub's listing pages publish it. Trimmed to the relevant fields, the markup on our MCP Memory Server page links a web page node to a software node through @id references:
[
{
"@context": "https://schema.org",
"@type": "WebPage",
"@id": "https://www.ithub.directory/mcp-servers/mcp-memory-server#webpage",
"publisher": { "@id": "https://www.ithub.directory/#organization" },
"mainEntity": { "@id": "https://www.ithub.directory/mcp-servers/mcp-memory-server#product" }
},
{
"@context": "https://schema.org",
"@type": "SoftwareApplication",
"@id": "https://www.ithub.directory/mcp-servers/mcp-memory-server#product",
"name": "MCP Memory Server",
"sameAs": "https://github.com/modelcontextprotocol/servers/tree/main/src/memory"
}
]
Each @id is a node, each property pointing at another @id is an edge, and sameAs ties the entity to its identity elsewhere on the web.
Enterprise knowledge graphs connect data from separate systems: customers, contracts and tickets; products, parts and suppliers; services, hosts and owners. Their value is in links no single system holds, such as which customers are exposed when a supplier fails.
Personal note graphs show the idea at small scale: Obsidian's graph view draws notes as nodes and internal links as lines (Obsidian Help), and Logseq builds a similar web of pages. The links carry no type, so a vault is a graph of documents rather than a knowledge graph.
How do you query a knowledge graph?
Here is the example graph from the diagram in both models. The data and queries below were run on November 21, 2026 with Apache Jena 5.1.0 for RDF and Neo4j 5.26 Community Edition for Cypher, and both return the same two rows.
In RDF, written in the Turtle syntax, the data and a minimal schema look like this:
@prefix ex: <https://example.com/kg/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
# schema
ex:dependsOn a rdf:Property ;
rdfs:domain ex:Service ;
rdfs:range ex:Library .
# data
ex:maya a ex:Person ; rdfs:label "Maya" ; ex:maintains ex:payments-api .
ex:sam a ex:Person ; rdfs:label "Sam" ; ex:maintains ex:checkout-web .
ex:payments-api a ex:Service ; rdfs:label "payments-api" ; ex:dependsOn ex:auth-lib .
ex:checkout-web a ex:Service ; rdfs:label "checkout-web" ; ex:dependsOn ex:auth-lib .
ex:auth-lib a ex:Library ; rdfs:label "auth-lib" .
One detail surprises newcomers: rdfs:domain and rdfs:range do not reject bad data. If something that is not a service gets a dependsOn edge, a reasoner concludes that it must be a service. Rejecting it is a job for SHACL.
The SPARQL query is a pattern of triples, with variables marked by ?:
PREFIX ex: <https://example.com/kg/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?serviceName ?maintainerName
WHERE {
?service ex:dependsOn ex:auth-lib ;
rdfs:label ?serviceName .
?maintainer ex:maintains ?service ;
rdfs:label ?maintainerName .
}
ORDER BY ?serviceName
In a property graph, the same data goes in with one Cypher CREATE statement. Note the version property on each relationship, which RDF 1.1 has no direct equivalent for:
CREATE (maya:Person {name: 'Maya'}),
(sam:Person {name: 'Sam'}),
(pay:Service {name: 'payments-api'}),
(web:Service {name: 'checkout-web'}),
(lib:Library {name: 'auth-lib'}),
(maya)-[:MAINTAINS]->(pay),
(sam)-[:MAINTAINS]->(web),
(pay)-[:DEPENDS_ON {version: '2.1'}]->(lib),
(web)-[:DEPENDS_ON {version: '1.9'}]->(lib);
The query draws the pattern, with parentheses for nodes and arrows for relationships:
MATCH (m:Person)-[:MAINTAINS]->(s:Service)-[d:DEPENDS_ON]->(:Library {name: 'auth-lib'})
RETURN s.name AS service, d.version AS version, m.name AS maintainer
ORDER BY service;
service version maintainer
checkout-web 1.9 Sam
payments-api 2.1 Maya
Both languages follow chains of any length, which is where graphs beat joins. If auth-lib itself depended on a library called crypto-core, the SPARQL pattern ?service a ex:Service ; ex:dependsOn+ ex:crypto-core . and the Cypher pattern (s:Service)-[:DEPENDS_ON*1..5]->(:Library {name: 'crypto-core'}) would both return every service that reaches it through one or more hops. In SQL, the same question needs a recursive common table expression.
How is a knowledge graph built?
- Start from questions. Write down what the graph must answer, such as which services are exposed to a CVE. Ontology designers call these competency questions; they decide what is worth modeling.
- Design a small schema. Name the entity types and relationship types, and reuse existing vocabularies such as schema.org where they fit. Adding a type later is cheap; untangling a vague one is not.
- Load structured sources first. Tables, APIs and configuration files map to nodes and edges with little ambiguity. For RDF, the W3C's R2RML standard describes mappings from relational databases (W3C R2RML).
- Extract from text. Named entity recognition and relation extraction, now often done with LLMs, turn documents and tickets into candidate facts. Extractors miss facts and invent some, so review them.
- Resolve entities. Decide when "IBM", "International Business Machines" and "ibm.com" are the same node. Entity resolution combines identifiers, normalized names and context, and is usually the hardest step.
- Link to shared identifiers. Attach Wikidata IDs, package names, domains or internal IDs so the graph connects to other datasets. RDF uses
owl:sameAsfor this; property graphs typically store the identifier as a property. - Validate and record provenance. Check data against constraints, store where and when each fact came from, and decide how facts get retired. Stale relationships are hard to spot.
How do knowledge graphs work with LLMs and GraphRAG?
Standard RAG splits documents into chunks, embeds them and retrieves the chunks most similar to the question. That works when the answer sits in one or two passages, and poorly for questions about a whole corpus ("what themes recur in these 5,000 tickets?") or questions that need several hops between facts.
GraphRAG, from Microsoft Research, adds a graph to that pipeline. During indexing, an LLM extracts entities, relationships and key claims from units of text. The resulting graph is clustered into a hierarchy of communities with the Leiden algorithm, and the LLM writes a summary of each community, from the bottom up (GraphRAG documentation). At query time, global search answers corpus-wide questions from community summaries, local search starts from specific entities and their neighbors, DRIFT search adds community context to local search, and basic search is plain vector retrieval.
The paper behind it, "From Local to Global: A Graph RAG Approach to Query-Focused Summarization" by Darren Edge and colleagues, reports substantial improvements over a conventional RAG baseline in the comprehensiveness and diversity of answers to global questions over datasets of about one million tokens (arXiv). The project's README warns that indexing can be expensive and advises starting small: every chunk passes through an LLM before your first question.
GraphRAG is one pattern among several. In text-to-Cypher or text-to-SPARQL, an LLM writes a query against an existing graph and the database returns exact facts; give the model a read-only database user. Hybrid retrieval runs a vector search to find entry nodes, then expands along their edges. Either way, the graph adds what embeddings lack: explicit relationships you can trace to a source.
Can a knowledge graph work as memory for AI agents?
Yes. The MCP Memory Server, one of the reference servers in the Model Context Protocol project, stores what an assistant learns as a local knowledge graph. Entities have a unique name, a type and a list of observations, which are single facts stored as strings. Relations are directed and written in active voice, such as works_at. The server exposes tools including create_entities, create_relations, add_observations, search_nodes and read_graph, and keeps everything in a JSON Lines file, memory.jsonl by default, whose location the MEMORY_FILE_PATH environment variable can change (MCP servers repository). If MCP is new to you, start with our guide to what an MCP server is.
The plain file lets you read what the agent remembers, delete wrong facts and keep memory under version control. The project presents its reference servers as educational examples, not production-ready software, and nothing stops an agent from creating "Maya" and "maya" as two entities: memory graphs need entity resolution too.
Other tools listed on iThub apply the same idea to code and documents. graphify maps code, docs and media into a knowledge graph that AI coding assistants can query, and Understand Anything turns a codebase or wiki into an interactive graph with guided tours. Cognee builds agent memory from documents, code and conversations by pairing a knowledge graph with vector retrieval.
Knowledge graph vs vector database vs relational database: which fits?
They answer different questions, and many systems combine two or three.
| Data model | Query language | Strengths | Typical use | |
|---|---|---|---|---|
| Knowledge graph (RDF) | Triples with global IRIs, described by RDFS or OWL | SPARQL | Merging data from many sources, shared vocabularies, standard inference | Open data, research and library metadata, data catalogs |
| Knowledge graph (property graph) | Nodes and relationships with labels and properties | Cypher, GQL | Multi-hop traversals, attributes on edges, flexible schema | Dependency and impact analysis, fraud detection, recommendations, agent memory |
| Relational database | Tables, rows and foreign keys | SQL | Transactions, constraints, aggregation, mature tooling | Orders, billing, accounts, most application back ends |
| Vector database | Embeddings with metadata | Similarity search APIs with filters | Finding text, images or code with similar meaning | Semantic search, RAG retrieval, deduplication |
In the knowledge graph vs vector database choice, the difference is what each one knows. A vector database such as Milvus or Weaviate finds content that means something close to the query, but it does not know that a service depends on a library, only that two texts are similar. A knowledge graph stores that dependency as a fact and follows it through five hops, but cannot rank paragraphs by meaning. Hence the common hybrid: vectors find starting points, the graph supplies relationships.
Relational databases cover more graph work than their reputation suggests. PostgreSQL handles hierarchies and moderate traversals with recursive queries, and a nodes table plus an edges table is a reasonable way to start. Move to a graph database when most queries are traversals of unknown depth, or when the SQL for them becomes slow and hard to read.
When do you not need a knowledge graph?
- Your questions are about rows, not connections. Reports, totals and CRUD screens belong in a relational database.
- The relationships are few and fixed. Two or three foreign keys do not need a graph engine.
- Similarity is the whole job. If users ask "find documents like this one", a vector index is simpler and cheaper.
- Nobody will own the schema. Without someone who decides what each type means and resolves duplicates, a graph fills up with near-identical nodes and stops being trustworthy.
- The indexing bill outweighs the gain. LLM extraction over a large corpus is costly, so test GraphRAG against plain RAG on a sample first.
Which tools can you use to build a knowledge graph?
Property graph databases
- Neo4j Is the database Cypher comes from; its browser-based tools draw query results as node-and-edge diagrams.
- Memgraph Is an in-memory graph database that also uses Cypher (Memgraph docs), with Memgraph Lab for visual exploration.
- Omnigraph Is an MIT-licensed Rust graph database that stores graphs on local disk or S3-compatible storage, with typed schemas, Git-style branches, vector search and MCP access.
- Kùzu Was an embedded option, but its developers archived the repository in October 2025. Existing releases keep working, and development continues in LadybugDB, whose README says the database was formerly known as Kuzu (Kùzu on GitHub, LadybugDB on GitHub).
- Apache AGE Is a PostgreSQL extension that adds openCypher queries next to SQL (Apache AGE).
RDF stores and libraries
- Apache Jena and Fuseki. Jena is a Java framework for RDF, and Fuseki its SPARQL server, supporting the SPARQL 1.1 query, update and graph store protocols (Apache Jena).
- GraphDB From Graphwise, formed by the merger of Ontotext and Semantic Web Company, is an RDF database with SPARQL 1.1 and reasoning over the RDFS, OWL 2 RL and OWL 2 QL rulesets. Since version 11.0, even the free edition requires requesting a free license.
- rdflib Is a Python library that parses RDF formats and runs SPARQL in memory, handy for scripts and tests.
Visualization
- Gephi and Cytoscape are open source desktop applications for visualizing and analyzing networks. For everyday query results, Neo4j's browser and Memgraph Lab are usually enough.
For more storage options, browse the databases and vector databases categories in the iThub directory.
Sources
- Introducing the Knowledge Graph: things, not strings, Google, May 16, 2012blog.google
- RDF 1.1 Concepts and Abstract Syntax, W3C Recommendationw3.org
- SPARQL 1.1 Query Language, W3C Recommendation, March 21, 2013w3.org
- OWL 2 Web Ontology Language Document Overview (Second Edition), W3C Recommendationw3.org
- Shapes Constraint Language (SHACL), W3C Recommendationw3.org
- ISO/IEC 39075:2024 Information technology, Database languages, GQL, ISO, April 2024iso.org
- GQL conformance, Neo4j Cypher Manualneo4j.com
- Wikidata: Introduction, Wikidatawikidata.org
- About Schema.org, Schema.orgschema.org
- From Local to Global: A Graph RAG Approach to Query-Focused Summarization, Edge et al., Microsoft Research, arXivarxiv.org
- GraphRAG documentation, Microsoftmicrosoft.github.io
- Knowledge Graph Memory Server, Model Context Protocol servers repositorygithub.com
Frequently asked questions
Is a knowledge graph the same as a graph database?
No. A graph database is a storage engine, such as Neo4j or Memgraph. A knowledge graph is data plus meaning: entities, typed relationships and a schema or ontology. You can store a knowledge graph in a graph database, an RDF triplestore, relational tables or even a JSON Lines file.
What is the difference between an ontology and a knowledge graph?
The ontology is the schema: the types of entities, the relationships allowed between them and the rules that apply. The knowledge graph is the ontology together with the instance data that follows it, such as specific people, services and libraries and the links between them.
Is GraphRAG better than vector RAG?
For questions about a whole corpus, Microsoft Research reported more comprehensive and more diverse answers than a conventional RAG baseline. For questions answered by one or two passages, plain vector RAG is cheaper and often enough. GraphRAG indexing runs every chunk through an LLM, so test both on a sample with your own questions.
Is Cypher the same as GQL?
No. GQL is the ISO/IEC 39075:2024 standard for property graph queries, published in April 2024. It adopted much of Cypher's style, including the MATCH and RETURN format, and Neo4j says Cypher supports most mandatory GQL features, though not yet all of them.
Can I build a knowledge graph in PostgreSQL?
Yes. A nodes table, an edges table and recursive queries handle many graph workloads, and the Apache AGE extension adds openCypher queries to PostgreSQL. A dedicated graph database becomes worth it when most queries traverse relationships of unknown depth.
How big does a knowledge graph need to be?
There is no minimum. An AI agent's memory graph may hold a few dozen entities, while Wikidata holds more than 124 million items. Size matters less than a clear schema, stable identifiers and someone responsible for keeping the facts correct.
Tools in this article
MCP Memory ServerA local knowledge-graph memory server that stores named entities, directed relations and observations for later retrieval.
ObsidianLocal Markdown note-taking app with links, graph, canvas, Bases and plugins, plus paid Sync and Publish
LogseqPrivacy-first open-source knowledge management and notes- GgraphifyA local-first skill that turns code and project documents into queryable knowledge graphs.
- UAUnderstand AnythingTurn a codebase or wiki into an interactive knowledge graph
CogneeCognee gives AI agents persistent memory built from documents, code, and conversations.
MilvusApache 2.0 vector database with Lite, Standalone and Kubernetes modes, plus managed Zilliz Cloud
WeaviateCloud-native vector database for semantic search and RAG
Facts link to their official sources. Product details can change after publication: report an error or read the editorial methodology.




