Sharding easy
In the context of database scaling, what is the fundamental difference between 'Vertical Partitioning' and 'Horizontal Partitioning' (Sharding)?
- A Vertical partitioning splits a table by columns (schema normalization); Horizontal partitioning splits a table's rows across multiple nodes.
- B Vertical partitioning is used only for relational databases, while Horizontal partitioning is exclusive to NoSQL systems.
- C Vertical partitioning involves moving data to faster SSDs; Horizontal partitioning involves adding more CPU cores.
- D Vertical partitioning creates backup copies, while Horizontal partitioning is used for real-time data encryption.
Answer: A. Vertical partitioning splits a table by columns (schema normalization); Horizontal partitioning splits a table's rows across multiple nodes.
Vertical scaling generally refers to upgrading a single machine's hardware, but 'Vertical Partitioning' specifically refers to splitting a table by its columns (e.g., separating rarely used large text fields into a different table to keep the main table slim). In contrast, 'Horizontal Partitioning' (Sharding) takes the rows and distributes them across multiple physical servers. This is the foundation of distributed databases, allowing a single logical table to grow beyond the storage and processing constraints of a single physical box.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In an E-Commerce platform, why might you choose to shard the `Orders` table by `user_id` rather than the more obvious `order_id`?
- If Shard A fails in a large cluster, and its incoming traffic is automatically re-routed to Shard B, what is the risk of a 'Cascading Failure'?
- In a standard 'Modulo Sharding' setup (`key % N`), what is the primary consequence of adding a new server to the cluster (increasing N from 10 to 11)?
- From an engineering perspective, when should you choose 'Vertical Scaling' (a bigger server) over 'Horizontal Scaling' (Sharding)?
- Which sharding strategy is mathematically optimized for efficient 'Range Scans' (e.g., retrieving all records created between January and March)?
- In a sharded architecture, what does the 'Scatter-Gather' query pattern imply for application performance?