Databases Reference
In-Depth Information
Now, if you get the record again, the output is as follows:
hbase(main):010:0> get 'products', 'product1'
COLUMN CELL
characteristics: acidity timestamp=1288555025970, value=low
characteristics: cultivatio timestamp=1288554998029, value=organic
n_method
source: country timestamp=1288555050543, value=yemen
source: terrain timestamp=1288555088136, value=mountainous
type:category timestamp=1288555272656, value=beans
type:genus timestamp=1288554961942, value=Coffea
type:name timestamp=1288554934169, value=Arabica
7 row(s) in 0.0370 seconds
Available for
download on
Wrox.com
products_hbase.txt
You may notice that the value for type:category is now beans instead of coffee beans . In reality,
both values are still stored as different versions of the same fi eld value and only the latest one of
these is returned by default. To look at the last four versions of the type:category fi eld, run the
following command:
hbase(main):011:0> get 'products', 'product1', { COLUMN => 'type:category',
VERSIONS => 4 }
COLUMN CELL
type:category timestamp=1288555272656, value=beans
type:category timestamp=1288554892522, value=coffee beans
There are only two versions so far, so those are returned.
Now, what if the data is very structured, limited, and relational in nature? It's possible HBase isn't
the right solution at all then.
HBase fl attens the data structure, only creating a hierarchy between a column-family and its
constituent columns. In addition, it also stores each cell's data along a time dimension, so you need
to fl atten nested data sets when such data is stored in HBase.
Consider the retail order system. In HBase, the retail order data could be stored in a couple of ways:
Flatten all the data sets and store all fi elds of an order, including all product data, in a
single row.
For each order, maintain all order line items within a single row. Save the product
information in a separate table and save a reference to the product row-key with the order
line item information.
Going with the fi rst option of fl attening the order data, you could end up making the following choices:
Create one column-family for regular line items and create another one for additional types
of line items like discount or rebate.
Within a regular line item column-family, you could have columns for item or product
name, item or product description, quantity, and price. If you fl atten everything, remember
Search WWH ::




Custom Search