A graph database stores entities as nodes and their connections as edges, then lets applications navigate and query those relationships directly. This structure suits knowledge-intensive applications where relationships, inference, and explainability matter more than simple similarity retrieval. section 10.5 section 1.2.1
A small graph
A person named Roberto can connect to a profession, a football team, and that team's league: (Roberto, hasOccupation, SoftwareDeveloper), (Roberto, isFanOf, InterMilan), and (InterMilan, playsIn, SerieA). The same facts can be represented as RDF subject-predicate-object triples or queried through systems such as Neo4j with Cypher and other systems with Gremlin. section 10.5
Figure 10.4 Graph representation of data. Nodes represent entities such as Roberto and InterMilan, while edges such as hasOccupation and isFanOf depict their relationships.
Use the graph representation to inspect how entity nodes and relationship edges encode facts that are difficult to capture in traditional database structures. section 10.5
In LLM applications, a graph database complements rather than replaces vector retrieval. It can preserve longer-lived entity relationships for memory and planning, while an LLM can extract graphs from unstructured text, generate Cypher or SPARQL from natural-language questions, and turn query results into answers. Reliable query generation requires schema-constrained prompts with examples and careful handling of generated statements. section 1.2.1 section 10.5
Figure 10.5 The Knowledge Graph RAG architecture (KG-RAG) is similar to vector store–based RAG setups, but it uses a SPARQL generator. The generator converts a natural language question into SPARQL, which is executed on the knowledge graph database. The retrieved graph data is then provided to the LLM, along with the original question, to synthesize the answer.
Follow the Knowledge Graph RAG flow from a natural-language question to generated SPARQL, graph execution, retrieved data, and synthesized response. section 10.5



