Beginners Guide to Apache HBase

Before understanding what is Apache HBase, we need to understand why It was introduced at first place.
Prior to apache HBase, we had Relation Database Management system (RDBMS) from late 1970’s , and it helped lot of companies to implement the solutions for their problems which are in use today.
Even today there are many uses cases where RDBMS is the perfect tool. Ex: Handling transactions, etc
Yet there are some problems like handling big data which cannot be solved through RDBMS .

Age of Bigdata

We live in an era where Peta bytes of data is generated on daily basis from sources like social media, e-commerce etc .Because of this, companies are focusing on delivering more targeted information, such as giving recommendations or online ads which influence their success as a business. With the Emergence of new machine learning algorithm,the need for collection of data have increased drastically and with collected data, technology like Hadoop is able to process it with ease.

In the past, Due to restrictions on cost required to store the data ,companies use to ignore historical data and used to retain only last N days data and keep all the remaining data as back up in tape drives.

Because of performing analytics on limited data ,resulting models were not effective.

Few companies like Google ,amazon etc, realized the importance of the data  and started developing the solutions for solving the big data problems.  These ideas were then implemented outside of Google as part of the open source Hadoop project: HDFS and Map Reduce.

But Hadoop was mainly introduced for batch processing but companies also needed a database which could be used for real-time responses.

So ,Google came up with the Bigtable, A column-oriented data base to address the real-time queries.

Before going deep into Apache HBase and its operations, let’s first understand Column-oriented database.

Column-oriented databases differ from row oriented traditional databases where entire rows are stored contiguously.

In Column-oriented database data are grouped by columns and subsequent columns are stored contiguously on the disk.

Storing values on a per column basis increases the efficiency when all the values are not needed.

In column-oriented database values of one column is very much similar in nature or even vary only slightly between logical rows and this makes them a very suitable candidate for compression when compared to the heterogeneous values of row oriented record structures.

Introduction Apache HBase

Apache HBase is the open source implementation of Google’s Big Table, with slight modifications.  It was created in 2007 , it was initially  a contributions to Hadoop  and it  later became a top level Apache project.

Apache HBase is a distributed column-oriented database built on top of the Hadoop file system  and it is horizontally scalable meaning we can add the new nodes to Hbase as data grows.

It is well suited for sparse data sets, which are common in many big data use cases.

An Apache HBase system comprises a set of tables. Each table contains rows and columns, much like a traditional database. Each table must have an element defined as a Primary Key, and all access attempts to HBase tables must use this Primary Key.

It is a part of the Hadoop ecosystem that provides random real-time read/write access to data in the Hadoop File System.


A Schema-less ,i.e there is no predefined schema for HBase tables.  RDBMS Tables have Fixed  schema, which describes the whole structure of tables.
Built for wide tables. It is horizontally scalable. It is thin and built for small tables. Hard to scale.
No transactions are there in HBase. RDBMS is transactional.
It has de-normalized data. It will have normalized data.
It is good for semi-structured as well as structured data. It is good for structured data.


We can interact with HBase in two different ways.

  • Through HBase interactive shell
  • HBase Java Client API

HBase shell is made up of JRuby( JRuby is Java implementation of the Ruby), we can login to that using below command

$HBASE_HOME/bin/hbase shell

Version command will display the version of HBase

List command will list all the tables present HBase

Basic commands and the structure

Column – A single field in table

Column-family – is group of columns

Row-key-Row-key in hbase is a mandatory field which serves as the unique identifier for every record.

Creating a table in HBase

Syntax : create ‘<table-name>’,’<column-family1>’ ,’<column-family2>’ …….

HBase data model, columns are grouped into column families, which must be defined during table creation. We must have at least one column family. HBase currently does not do well with above three column families so keep the number of column families in your schema low.


Inserting the data into HBase

We can insert the data using PUT command

Syntax: put ‘<table-name>’,’row-key’,’columnfamily:columnname’,’value’

Row-key is a mandatory field which serves as the unique identifier for every record.

Here in the below description customer is the table name and john is the row key followed by column family and its value.

Inserting second record

Getting single record from table


We should use GET command to retrieve single record from HBase table,

Syntax: get ‘<table-name>’,’<row-key>’,’<column-family>’

Using get command to retrieve the address of john

Using get command to retrieve city of john

To get the all the records from the table we should use scan command.

Syntax : scan ‘<table -name>’

Deleting records

Deleting entire record from table

Deleting specific column from table

Counting number of rows in the table

Version in Apache HBase

Updating tables means replacing the previous value with the new one. But in HBase, if we try to rewrite the column values, it does not overwrite the existing value but rather stores different values per row by time (and qualifier). Excess versions are removed during major compaction. The number of max versions may need to be increased or decreased depending on application needs.

The default version is 1, we can modify and increase or decrease the versions  to be stored using alter command:

Dropping table

Before dropping the table we must disable the table by using below syntax:

disable ‘table-name’

Now, you can drop the table using below syntax:

drop ‘table-name’

We hope this blog helped you in getting a brief overview of HBase and its implementation in Hadoop. Keep visiting for more updates on Big Data and other technologies. Click here to learn Big Data Hadoop Development.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s