Concept 1 / 8
What Is a Graph Database?
A graph database stores and queries data modeled as a network of nodes and edges. The formal definition is G = (V, E, λ_V, λ_E), where V is the node set, E is the edge set (directed or undirected), λ_V assigns attributes to nodes, and λ_E assigns attributes to edges.
Three core building blocks:
- Nodes: entities (e.g., persons, movies, proteins)
- Edges: directed relationships between nodes (e.g., FOLLOWS, ACTED_IN)
- Properties: key-value pairs attached to nodes or edges (e.g.,
name: 'Alice',since: 2020)
Additionally, node labels (tags identifying the entity type, like Person or Movie) and edge names (the relationship type, like KNOWS) are first-class metadata.
Key difference from relational databases: In a relational DB, relationships are represented by foreign-key joins computed at query time. In a graph DB, joins are implicit in the schema — related nodes point to each other directly in the underlying storage, making traversals constant-time per hop.
(Ruth:User)-[:FOLLOWS]->(Harry:User)
(Harry:User)-[:FOLLOWS]->(Billy:User)Finding all of Ruth's followers' followers is a breadth-first search from the "Ruth" node — no recursive SQL join needed.