- 2075 Bhadra · 10 marks
Column vs row-oriented NoSQL databases
Short answer
HBase and Cassandra are column-family stores, while MongoDB is a document store. Row-oriented databases store entire rows together, optimizing OLTP; column-oriented stores store columns together, speeding up analytical queries on few columns by reading only necessary data, offering better compression and handling sparse data.
Hbase, Cassandra and MongoDB are called column-oriented NoSQL database? How row-oriented database differ from column-oriented database? Explain with suitable examples.
Are HBase, Cassandra and MongoDB column-oriented?
Strictly, only HBase and Cassandra are called column-family (wide-column) stores. They are modelled on Google's BigTable: data is organised into rows and column families, columns can be added freely per row, and data of a column family is stored together on disk. HBase has rows -> column families -> qualifiers -> versioned cells. Cassandra has keyspaces -> column families (tables) -> rows with dynamic columns.
MongoDB is not column-oriented. It is a document store: it saves data as JSON-like (BSON) documents. It is often grouped loosely with the "NoSQL" family, but its storage unit is the document, not the column family. So the statement is correct for HBase and Cassandra, but wrong for MongoDB.
Row-oriented vs column-oriented databases
A row-oriented database stores all values of a row contiguously on disk (e.g. MySQL, Oracle). A column-oriented database stores the values of one column (or column family) contiguously.
Example table:
| ID | Name | Age | City |
|---|---|---|---|
| 1 | Ram | 25 | Kathmandu |
| 2 | Sita | 30 | Pokhara |
| 3 | Hari | 28 | Butwal |
Row-oriented layout on disk:
[1,Ram,25,Kathmandu][2,Sita,30,Pokhara][3,Hari,28,Butwal]
Column-oriented layout on disk:
ID: [1,2,3]
Name: [Ram,Sita,Hari]
Age: [25,30,28]
City: [Kathmandu,Pokhara,Butwal]
| Point | Row-oriented | Column-oriented |
|---|---|---|
| Storage | Whole row together | Column together |
| Best for | OLTP: insert/update/read whole record | OLAP/analytics: aggregates on few columns |
Query AVG(Age) | Reads all columns of every row | Reads only the Age column |
| Insert a new record | Fast, one write | Slower, touches many column files |
| Compression | Less effective (mixed types) | High (same type values together) |
| Schema | Fixed, rigid | Flexible, columns added on the fly (HBase, Cassandra) |
| Sparse data | Wastes space with NULLs | Missing cells simply not stored |
| Examples | MySQL, PostgreSQL, Oracle | HBase, Cassandra, Vertica |
Summary
Query "average age of all people" is faster in a column store as only the Age column is read. Query "show everything about person 2" is faster in a row store as one contiguous read gives the whole row. Big-data systems like HBase and Cassandra favour column-family storage because of high write throughput, scalability and sparse wide tables.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Structured vs unstructured, NoSQL taxonomy · Big Data Technologies, chapter 4
- DMQL; transactional vs warehouse database · Data Mining, chapter 2
- DW characteristics vs operational database · Data Mining, chapter 1
- RDBMS vs DW database; DW terms · Data Mining, chapter 1
- Data warehouse vs database · Data Mining, chapter 1