Skip to main content

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:

IDNameAgeCity
1Ram25Kathmandu
2Sita30Pokhara
3Hari28Butwal
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]
PointRow-orientedColumn-oriented
StorageWhole row togetherColumn together
Best forOLTP: insert/update/read whole recordOLAP/analytics: aggregates on few columns
Query AVG(Age)Reads all columns of every rowReads only the Age column
Insert a new recordFast, one writeSlower, touches many column files
CompressionLess effective (mixed types)High (same type values together)
SchemaFixed, rigidFlexible, columns added on the fly (HBase, Cassandra)
Sparse dataWastes space with NULLsMissing cells simply not stored
ExamplesMySQL, PostgreSQL, OracleHBase, 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)

All Big Data Technologies chapter 4 questions →