Which statement best describes the difference between sharding and partitioning in databases?
Think about whether the data is split across machines or within one machine.
Sharding means splitting data horizontally across different servers or machines to distribute load. Partitioning divides data into parts but usually within the same machine or database instance.
Which of the following is the best choice for a sharding key in a user database?
The sharding key should evenly distribute data and be stable.
A unique ID number is stable and evenly distributed, making it a good sharding key. Email or timestamps can be uneven or change over time.
What is the main problem caused by uneven data distribution across shards?
Consider what happens if one shard holds much more data than others.
When data is unevenly distributed, some shards handle more requests and data, leading to slower performance and risk of failure, while others are underused.
Which statement correctly compares horizontal and vertical partitioning?
Think about whether partitioning divides data by rows or columns.
Horizontal partitioning divides a table's rows into smaller sets. Vertical partitioning divides a table's columns into smaller sets.
A global social media app wants to shard its user data to improve performance. Which sharding strategy is best to reduce latency for users worldwide?
Consider how physical location affects network speed and latency.
Sharding by geographic region places user data closer to their location, reducing network delays and improving response times.