Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 36 ยท Getting Started

HBase vs RDBMS and Other NoSQL Stores

Compare Apache HBase with relational databases, Cassandra, MongoDB and Redis, and learn the questions that decide which database fits your workload.

"Which database should I use?" is rarely answered by a feature list. It is answered by your access patterns: how you read, how you write, how big the data gets, and what can go wrong. This lesson compares HBase with relational databases (RDBMS) and with the three NoSQL families people most often confuse it with, then gives you a short decision checklist.

Before you start, make sure you know what HBase is from What Is Apache HBase?. The comparisons below are simplified on purpose; each product has many settings that move it toward or away from these descriptions.

HBase vs a relational database

A relational database stores rows in tables with a fixed schema, enforces constraints, supports joins, and offers ACID transactions across many rows and tables. It is tuned for flexible queries on data that usually fits on one (possibly large) server.

HBase gives up much of that to scale horizontally.

Aspect RDBMS (PostgreSQL, MySQL) HBase
Schema Fixed columns, types enforced Column families fixed; qualifiers free; values are bytes
Query language SQL, joins, aggregates Get, Put, Scan, Delete (SQL only through add-ons)
Indexes Many, including secondary Row key only
Transactions Multi-row, multi-table ACID Atomic per row
Scaling Vertical first; sharding is manual work Horizontal; regions split automatically
Typical size Gigabytes to a few terabytes Terabytes to petabytes
Missing values NULL takes space or a flag Nothing is stored

The biggest mental shift is data modeling. In an RDBMS you model your entities and then write whatever queries you need. In HBase you model your queries first, because the row key decides what is fast. Denormalizing (storing the same fact in several places) is normal.

The following Java stand-in shows the difference. In a relational style, finding orders for a user requires a scan of the orders table unless you add an index. In the HBase style, the user ID is the first part of the row key, so all of one user's orders are neighbors in the sorted map.

Java Stand-in: row key design makes the query cheap

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

HBase vs Cassandra

Both descend from the Bigtable and Dynamo ideas and both scale horizontally. The main differences are architectural.

  • Consistency. HBase is strongly consistent per row: one RegionServer owns a row at any time. Cassandra is a peer-to-peer system with tunable consistency; by default you accept eventual consistency in exchange for availability during failures.
  • Architecture. HBase has a Master, RegionServers, ZooKeeper and HDFS. Cassandra is a single kind of node with no master and no external file system.
  • Scans. HBase is built for ordered range scans over big row ranges and integrates tightly with Hadoop. Cassandra orders data inside a partition but spreads partitions by hash, so cross-partition scans are not its strength.
  • Query language. Cassandra ships CQL, which looks like SQL. HBase needs an add-on for SQL.

If you already run Hadoop and need strong row consistency and large ordered scans, HBase fits. If you need multi-datacenter writes everywhere and simpler operations, Cassandra often wins.

HBase vs MongoDB

MongoDB stores JSON-like documents and supports secondary indexes, rich queries and aggregation. Its sweet spot is flexible application data with varied queries. HBase has no document model and no secondary indexes; it is better when the dataset is far larger and the access pattern is a simple key or key range.

HBase vs Redis

Redis keeps data in memory and answers in microseconds, but your data size is limited by RAM. HBase keeps data on disk (with caches in memory) and goes to petabytes at millisecond latencies. They are often used together: Redis as a cache in front of HBase.

Pick by access pattern

Joins and reports Relational database
Flexible documents MongoDB or similar
Cache in RAM Redis
Huge key ranges HBase

Often a system uses two or three of these together.

1 / 2

A decision checklist

Ask these questions in order. The first "yes" in the left column points you away from HBase.

  1. Does the data comfortably fit on one server for the next few years? If yes, start with an RDBMS.
  2. Do you need joins, ad-hoc filters on many columns or multi-row transactions? If yes, an RDBMS or document store is simpler.
  3. Is access mostly by a key or a key range, with very high volume? Then HBase is a candidate.
  4. Do you need strong consistency for each record? HBase gives it; many alternatives do not by default.
  5. Can your team run Hadoop and ZooKeeper, or buy a managed service? If not, the operational cost may outweigh the benefits.

Here is a final stand-in that turns this checklist into code. It is only a teaching toy, but writing the rules down helps you see which facts matter.

Java Stand-in: a tiny database advisor

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which statement about transactions in HBase is correct?

    HBase guarantees atomicity for operations on one row, even across column families, but not across rows or tables.
  2. 2. What is the biggest change in thinking when moving from an RDBMS to HBase?

    Because only the row key is indexed, access patterns drive the design, and duplicating data is normal.
  3. 3. Compared with Cassandra, HBase by default...

    A region is served by one RegionServer, so reads see the latest write to a row. Cassandra is masterless and tunable.
  4. 4. Your whole dataset is 3 GB and you need joins. What should you pick?

    HBase's machinery and limits are not justified for small, join-heavy data.

Summary

  • HBase trades joins, secondary indexes and multi-row transactions for horizontal scale and key-range speed.
  • You model queries first and denormalize freely.
  • Versus Cassandra: HBase has a master, strong per-row consistency and Hadoop integration.
  • Versus MongoDB or Redis: HBase wins on size and ordered scans, loses on flexibility and raw latency.
  • Decide by access pattern, size and operational capacity, not by fashion.

Next: Installing HBase and Standalone Mode