> What is **connected** to this, and how? ^question ## Definition > A [[Database|database]] where: > - [[Notes/Index|Index]] [[Adjacency list]] (1-[[Hop]]) > - [[Query]]: [[Path]] ([[Multi-hop]]) ^definition ## Example: ```json { "database": [ ], "graph": [ ], "vector": [ ], "graph DB": [ "graph", "database" ], "vector DB": [ "vector", "database" ], "hybrid DB": [ "graph DB", "vector DB" ] } ``` ^example The core architectural difference from relational databases: each node directly stores physical pointers to its neighbouring nodes. Traversal cost is **constant per hop** regardless of graph size — no joins computed at query time. In a relational database, each additional [[Hop]] requires an additional join, and query complexity grows exponentially with traversal depth. ^index-free-adjacency ## What it solves - **Deep multi-hop traversal** (5+ hops) at constant cost per hop - **Complex path queries** - [[Shortest path]], all paths between nodes - **Graph algorithms** — PageRank, community detection, centrality - **Relationship-rich data** — when edges carry as much meaning as nodes (typed, weighted, timestamped edges) ^what-it-solves - [[Multi-hop]] reasoning ("what does A's supplier depend on?") - Path and reachability queries ([[Shortest path]], ancestry, citation chains) - Aggregation queries ("how many documents mention X and Y in the context of Z?") - Permission and ownership encoded as relationships - Audit-grade retrieval where the trail of edges must be inspectable ## When to use vs alternatives Use a dedicated graph database when: - Queries traverse 5+ [[Hop|hops]] at scale - Relationships themselves carry rich data - Graph algorithms are needed (PageRank, community detection, [[Shortest path|shortest path]]) For most knowledge base use cases — search + 1–2 hop context loading — an adjacency list model in a relational database is sufficient and avoids the operational overhead of a separate system. [^1] ^when-to-use ## Cost Graph databases have a heavy cold start: [^4] - **Entity resolution** - "Microsoft Corp", "Microsoft", and "MSFT" must collapse to one node before the graph is usable - **Schema design** - someone has to decide which relationship types matter - **Extraction pipelines** - parsing raw text into nodes and edges, usually with tuned prompts or specialised models - **Operational expertise** - graph theory, Cypher or Gremlin, and the domain [^1]: [Exploring Graph Database Capabilities: Neo4j vs. PostgreSQL](https://medium.com/self-study-notes/exploring-graph-database-capabilities-neo4j-vs-postgresql-105c9e85bb5d). Medium. [^4]: [Vector Databases vs. Graph RAG for Agent Memory: When to Use Which - MachineLearningMastery](https://machinelearningmastery.com/vector-databases-vs-graph-rag-for-agent-memory-when-to-use-which/)