hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Imran M Yousuf <imyou...@gmail.com>
Subject Re: How to Map One to Many relations on HBase?
Date Sat, 21 Aug 2010 03:55:30 GMT
Hi!

On Fri, Aug 20, 2010 at 5:46 PM, Shuja Rehman <shujamughal@gmail.com> wrote:
> Hi All
>
> I am new to HBase and I have one question which can be best described by the
> following scenario.
>
> Suppose I have three tables BaseCategory,Category and products. If i am
> thinking in terms of RDBMS then the relationship amoung these tables are
>
> 1- One BaseCategory has Many categories
>
> 2- One Category has Many Products.
>
> Now i am thinking to convert it into HBase. can anybody help me how to map
> these relations into HBase? I am thinking about this schema but not sure my
> direction is right.
>

First of all, we have to keep in mind the basic difference between a
RDBMS and BigTable row structure - RDBMS row is one directional while
BigTable row is 2 dimensional.
Keeping this in mind we could go for a lot combination of design
depending on DTO nature and our use cases. For example, if
BaseCategory object, as Ryan mentioned in his email, could be part of
another column family in the category row. So for BaseCategory and
Category I would, a possibility, have 2 tables but with duplication
and ensuring both way relationship.

Table: BaseCategory
RowID | BaseCat_Family    | Cats_Family |
----------------------------------------
*key*   | BaseCatId:id         | cat1:cat_id1  |
          | BaseCatInfo:info    | cat2:cat_id2  |
          | BaseCatDesc:Desc |
----------------------------------------

Table: Category
RowID | BaseCat_Family    | Cat_Family  |
----------------------------------------
*key*   | BaseCatId:id         | name:name  |
          | BaseCatInfo:info    | info:info       |
          | BaseCatDesc:Desc | desc:desc     |
          | BaseCatKey:key     |
----------------------------------------

This sort of design has its advantages and disadvantages. The
advantage would be that when a category is loaded its base category
would be loaded as well not needing any additional lookup to form the
category object. Looking up all categories for a base category would
also be easy since loading the base category would allow us to have
all its categories. The disadvantage on the other hand would be that
edit to a base category means a column family of category being edited
as well; but given the usual read/write ratio I would say it could be
more of an advantage.

I hope that I could explain how you could go about perceiving the
design, now you can work up the options and see which is best suited
for you. If you have any further questions please fire away.

Best regards,

Imran

>
>  *Row Key*
>
> *Column Families*
>
> Base Category ID
>
> Base Category Info:
>
> Categories:
>
>
>
> Base Category Info:Name
>
> Base Category Info:Description
>
> Categories:catName
>
>
>
>
>
>
>
>
>
>
>
>
>
>  *Row Key*
>
> *Column Families*
>
> Category Name
>
> Category Info:
>
> Product:
>
>
>
>  Category Info:Name
>
>  Category Info:Description
>
> Prodcut:Name
>
> Prodcut:Quantity
>
> Prodcut:Price
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>  --
> Regards
> Shuja-ur-Rehman Baig
> http://pk.linkedin.com/in/shujamughal
> Cell: +92 3214207445
>



-- 
Imran M Yousuf
Entrepreneur & CEO
Smart IT Engineering Ltd.
Dhaka, Bangladesh
Email: imran@smartitengineering.com
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557

Mime
View raw message