Junior — Middle
How does vertical data partitioning differ from horizontal in database or system architecture?
sobes.tech AI
Answer from AI
Vertical and horizontal data partitioning are two different approaches to scaling and organizing data in systems and databases.
-
Vertical Partitioning
- Data is split by columns (attributes).
- For example, a table with many columns can be divided into several tables, each containing a subset of columns.
- Used to optimize access to frequently used columns and reduce the volume of data transferred.
- Example: a user table is split into a main data table (name, email) and an additional data table (address, phone).
-
Horizontal Partitioning (or Sharding)
- Data is split by rows.
- Each part contains a subset of records, for example, by key range or geographic region.
- Used to distribute load and increase scalability.
- Example: a customer database is partitioned by regions, with each region stored on a separate server.
Thus, vertical partitioning divides data by columns, while horizontal partitioning divides data by rows.