Balamurugan Rajendran pisze:
Dear

>From the document http://blog.rapleaf.com/dev/?p=26, I understand that
one-to-many relationship can be captured using the column family.

Is there any example that shows how an one-to-many relationship value
in RDBMS can be captured using the column family of HBASE.
Let's say you want to store relationship:
Author published many Books

Below is the example executed in the Hbase shell

You create table authors with column birth and books to store the birth date and all books published

> create 'authors', 'birth', 'books'

then you put values into this table - lets assume that authors names are unique and we can use them as row keys
birth date first:

> put 'authors', 'Tolkien_John Ronald Reuel', 'birth:', '1892-01-03'

then use column family labels to store many books in the same column

>put 'authors', 'Tolkien_John Ronald Reuel', 'books:Hobbit', 'some information about the book - can be serialized' >put 'authors', 'Tolkien_John Ronald Reuel', 'books:Silmarillion', 'some information about the book - can be serialized' >put 'authors', 'Tolkien_John Ronald Reuel', 'books:The_Lord_of_The_Rings', 'some information about the book - can be serialized'

then you can select all the books written by Tolkien by:

>  get 'authors', 'Tolkien'

and you get something like:

>COLUMN CELL > birth: timestamp=1227603058478, value=1892-01-03 > books:Hobbit timestamp=1227603168560, value=some information about the book - can be serialized > books:Silmarillion timestamp=1227603185479, value=some information about the book - can be serialized > books:The_Lord_of_The_Rings timestamp=1227603206863, value=some information about the book - can be serialized
>4 row(s) in 0.0080 seconds


Or you could use PIGI indexing for this http://www.pigi-project.org/ - it supports indexing, paging, searching, ordering, one to many
relationship in Hbase




krzysiek szlapinski

Reply via email to