Modeling Connections Directly
A graph database stores data as nodes and relationships between them. Both nodes and relationships carry properties. A person node can have a knows relationship to another person node, and that relationship can hold its own data like a since year.
Why Not Just Use Joins
In a relational database, traversing many hops means repeated joins through a join table, and cost grows quickly with depth. A graph database stores each relationship as a direct pointer from one node to another, so following an edge is a constant time hop regardless of total data size. This is called index free adjacency.
What It Is Good For
- Social graphs asking who is connected to whom within several hops.
- Recommendations like people who bought this also bought that.
- Fraud detection spotting suspicious chains of accounts and transactions.
When to Avoid It
If your queries are mostly simple lookups or aggregations over independent rows, a graph database adds complexity for little gain. The model pays off when relationships and traversals are the heart of the question.
Key idea
A graph database treats relationships as first class pointers, making deep connected traversals fast where repeated relational joins would be costly.