Data Modeling medium
When should you switch from a Relational DB to a Graph DB (Neo4j)?
- A When the dataset grows beyond ten terabytes and the relational database's internal partitioning logic becomes fundamentally unable to handle horizontal scaling.
- B When the application requires optimized, high-velocity write throughput for millions of independent, non-relational event logs across several disparate regions.
- C When the data is highly interconnected and query performance depends on traversing many relationships (e.g., 'Friends of Friends') that would choke standard SQL JOINs.
- D When strict, multi-row ACID compliance is the primary requirement for a financial transaction system that must maintain absolute consistency at any cost.
Answer: C. When the data is highly interconnected and query performance depends on traversing many relationships (e.g., 'Friends of Friends') that would choke standard SQL JOINs.
Graph databases (like Neo4j) utilize 'Index-Free Adjacency', where each node stores direct pointers to its neighbors. This makes 'pointer chasing' an O(1) operation. In contrast, relational databases must perform expensive, high-complexity set-joins (O(N log N)) for every level of a relationship. For social networks, fraud detection, or recommendation engines, a Graph DB offers order-of-magnitude performance gains over SQL.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- When modeling a Distributed Transaction using the Saga Pattern (Choreography or Orchestration), what type of consistency do you achieve?
- Which practice prevents SQL Injection attacks?
- What is 'Bi-Temporal' data modeling (e.g., in SQL:2011 standard)?
- Adding an Index to a database column generally improves Read performance. What is the negative trade-off?
- Log Systems Merge (LSM) Trees (used in RocksDB, Cassandra) optimize for fast writes. What is their primary downside regarding Disk I/O?
- What is the primary objective of normalizing a relational database schema (e.g., to 3NF)?