You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Stuti Awasthi <st...@hcl.com> on 2011/08/17 17:18:31 UTC

Hbase query

Hi all

I have read that Hbase query will depend on <Row-Key> only . I was trying to map my tables of RDBMS to HBASE and was thinking way out for the following ?

RDBMS Schema :

Table Sales
Column:

*         Sales_Id (PK)

*         User_Id     (FK)

*         Product_ID (FK)

*         Name

*         Mobile

*         Email

Query : Select Name , Mobile, Email from Sales where User_id= "xyz" and Product_Id= "123"

This query is fairly simple in RDBMS because we can query based on columns. How to do this efficiently in Hbase ?



________________________________
::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------

Re: Hbase query

Posted by Christopher Tarnas <cf...@email.com>.
Hi Stuti,

There are several approaches depending on your exact situation, but most
involve secondary indexes. You should read the HBase book, specifically the
chapter on secondary indexes:

http://hbase.apache.org/book.html#secondary.indexes

-chris


On Wed, Aug 17, 2011 at 10:18 AM, Stuti Awasthi <st...@hcl.com>wrote:

> Hi all
>
> I have read that Hbase query will depend on <Row-Key> only . I was trying
> to map my tables of RDBMS to HBASE and was thinking way out for the
> following ?
>
> RDBMS Schema :
>
> Table Sales
> Column:
>
> *         Sales_Id (PK)
>
> *         User_Id     (FK)
>
> *         Product_ID (FK)
>
> *         Name
>
> *         Mobile
>
> *         Email
>
> Query : Select Name , Mobile, Email from Sales where User_id= "xyz" and
> Product_Id= "123"
>
> This query is fairly simple in RDBMS because we can query based on columns.
> How to do this efficiently in Hbase ?
>
>
>
> ________________________________
> ::DISCLAIMER::
>
> -----------------------------------------------------------------------------------------------------------------------
>
> The contents of this e-mail and any attachment(s) are confidential and
> intended for the named recipient(s) only.
> It shall not attach any liability on the originator or HCL or its
> affiliates. Any views or opinions presented in
> this email are solely those of the author and may not necessarily reflect
> the opinions of HCL or its affiliates.
> Any form of reproduction, dissemination, copying, disclosure, modification,
> distribution and / or publication of
> this message without the prior written consent of the author of this e-mail
> is strictly prohibited. If you have
> received this email in error please delete it and notify the sender
> immediately. Before opening any mail and
> attachments please check them for viruses and defect.
>
>
> -----------------------------------------------------------------------------------------------------------------------
>

RE: Hbase query

Posted by Stuti Awasthi <st...@hcl.com>.
Thanks Buttler !

-----Original Message-----
From: Buttler, David [mailto:buttler1@llnl.gov] 
Sent: Wednesday, August 17, 2011 9:13 PM
To: user@hbase.apache.org
Subject: RE: Hbase query 

One way to do it would be to drop the sales_id and use a composite key of user_id/product_id (assuming that a user may only by one product).  Then you could do a simple get("xyz/123") to get the full row.  If you wanted to get the email of people who bought product "123", then a row key of product/user might be more useful. Then you could scan starting at "123", ending at "123\0".  

However, you need to ask the question: Since you already have an RDBMS that works, why do you want to switch to HBase?  If it is because you have a lot of transaction data (really? Main memory is getting pretty big these days...), maybe you want to store user info in the RDBMS and just the transaction data in HBase.

Dave

-----Original Message-----
From: Stuti Awasthi [mailto:stutiawasthi@hcl.com]
Sent: Wednesday, August 17, 2011 8:19 AM
To: user@hbase.apache.org
Subject: Hbase query 

Hi all

I have read that Hbase query will depend on <Row-Key> only . I was trying to map my tables of RDBMS to HBASE and was thinking way out for the following ?

RDBMS Schema :

Table Sales
Column:

*         Sales_Id (PK)

*         User_Id     (FK)

*         Product_ID (FK)

*         Name

*         Mobile

*         Email

Query : Select Name , Mobile, Email from Sales where User_id= "xyz" and Product_Id= "123"

This query is fairly simple in RDBMS because we can query based on columns. How to do this efficiently in Hbase ?



________________________________
::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any mail and attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------

RE: Hbase query

Posted by "Buttler, David" <bu...@llnl.gov>.
One way to do it would be to drop the sales_id and use a composite key of user_id/product_id (assuming that a user may only by one product).  Then you could do a simple get("xyz/123") to get the full row.  If you wanted to get the email of people who bought product "123", then a row key of product/user might be more useful. Then you could scan starting at "123", ending at "123\0".  

However, you need to ask the question: Since you already have an RDBMS that works, why do you want to switch to HBase?  If it is because you have a lot of transaction data (really? Main memory is getting pretty big these days...), maybe you want to store user info in the RDBMS and just the transaction data in HBase.

Dave

-----Original Message-----
From: Stuti Awasthi [mailto:stutiawasthi@hcl.com] 
Sent: Wednesday, August 17, 2011 8:19 AM
To: user@hbase.apache.org
Subject: Hbase query 

Hi all

I have read that Hbase query will depend on <Row-Key> only . I was trying to map my tables of RDBMS to HBASE and was thinking way out for the following ?

RDBMS Schema :

Table Sales
Column:

*         Sales_Id (PK)

*         User_Id     (FK)

*         Product_ID (FK)

*         Name

*         Mobile

*         Email

Query : Select Name , Mobile, Email from Sales where User_id= "xyz" and Product_Id= "123"

This query is fairly simple in RDBMS because we can query based on columns. How to do this efficiently in Hbase ?



________________________________
::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------