You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Sujee Maniyam <s...@sujee.net> on 2009/09/30 00:10:50 UTC

table design suggestions...

HI all,
I am in the process of migrating  a relational table to Hbase.

Current table:  records user access logs
    id  : PK
    userId
    url
    timestamp
    refer_url
    ip_address
    cc   : country code of ip address

my potential queries would be
    - grab all pages visited by a user
    - generate a report of country : number of page views

I want to understand the implications of different Hbase
implementations and how they might affect queries.

A)  similar case study
(http://www.slideshare.net/hmisty/20090713-hbase-schema-design-case-studies)
recommends using timestamp as key (actually timestamp + counter).

timestamp + counter  =>  {
   user => {
        userId
   }

   url => {
        url:
   }

   from => {
    ip_address
    referer_url
    cc
   }
}



B) I am wondering if I can use 'user' as key,   but since there are
going to be multiple logs per user, one possiblity might be
    'userid + timestemp' as key

I have seen this :
http://www.nabble.com/Advice-on-table-design-td21110283.html#a21110283

userid + timestamp => {
   url => {
        url:
   }

   from => {
    ip_address
    referer_url
    cc
   }
}


C) I am also wondering since cells are versioned with timestamps, I
can use it to represent multiple requests from the same user to same
url
   userid => {
        url => {
        }

        from => {
            ip_address
            ...
        }
   }


Any suggestions are most appreciated.

thanks
SM

Re: table design suggestions...

Posted by Amandeep Khurana <am...@gmail.com>.
On Tue, Sep 29, 2009 at 11:28 PM, Sujee Maniyam <su...@sujee.net> wrote:

> > You can either create 2 tables. One can have the user as the key and the
> > other can have the country as the key..
> >
> > Or.. you can create a single table with user+country as the key.
> >
> > Third way is to have only one table with user as the key. For the country
> > query you can scan across the table and do aggregations.
> >
> > The choice will depend on whether these are batch processed queries or
> real
> > time.
> >
>
> Amandeep
> Thanks for your reply.
> If I have user as key, how would I store multiple records for the same
> user (as there would be multiple page views from a user).  I am
> thinking I need to couple it with timestamps?
>   userid_timestamp => { }
>
>
You can store in separate columns under the same family...

I'm not sure why you would want timestamp in the key.. Does it solve any
other issue?


> thanks
> SM
>

RE: table design suggestions...

Posted by "Wim Van Leuven (highestpoint)" <wi...@highestpoint.biz>.
I saw some implemenations/examples using combined keys as
<key1>_<key2>_<Long.MAX-now().inMilliseconds()>. 

This way you can subselect on key1/key2/time; in your case this would just
be use/time. Not time becomes ascending due to the (max-now) rule, so your
latest additions come first.

HTH
-wim

-----Original Message-----
From: Sujee Maniyam [mailto:sujee@sujee.net] 
Sent: woensdag 30 september 2009 8:29
To: hbase-user@hadoop.apache.org
Subject: Re: table design suggestions...

> You can either create 2 tables. One can have the user as the key and the
> other can have the country as the key..
>
> Or.. you can create a single table with user+country as the key.
>
> Third way is to have only one table with user as the key. For the country
> query you can scan across the table and do aggregations.
>
> The choice will depend on whether these are batch processed queries or
real
> time.
>

Amandeep
Thanks for your reply.
If I have user as key, how would I store multiple records for the same
user (as there would be multiple page views from a user).  I am
thinking I need to couple it with timestamps?
   userid_timestamp => { }

thanks
SM


Re: table design suggestions...

Posted by Sujee Maniyam <su...@sujee.net>.
> You can either create 2 tables. One can have the user as the key and the
> other can have the country as the key..
>
> Or.. you can create a single table with user+country as the key.
>
> Third way is to have only one table with user as the key. For the country
> query you can scan across the table and do aggregations.
>
> The choice will depend on whether these are batch processed queries or real
> time.
>

Amandeep
Thanks for your reply.
If I have user as key, how would I store multiple records for the same
user (as there would be multiple page views from a user).  I am
thinking I need to couple it with timestamps?
   userid_timestamp => { }

thanks
SM

Re: table design suggestions...

Posted by Amandeep Khurana <am...@gmail.com>.
comments inline


Amandeep Khurana
Computer Science Graduate Student
University of California, Santa Cruz


On Tue, Sep 29, 2009 at 3:10 PM, Sujee Maniyam <s...@sujee.net> wrote:

> HI all,
> I am in the process of migrating  a relational table to Hbase.
>
> Current table:  records user access logs
>    id  : PK
>    userId
>    url
>    timestamp
>    refer_url
>    ip_address
>    cc   : country code of ip address
>
> my potential queries would be
>    - grab all pages visited by a user
>    - generate a report of country : number of page views
>
>
You can either create 2 tables. One can have the user as the key and the
other can have the country as the key..

Or.. you can create a single table with user+country as the key.

Third way is to have only one table with user as the key. For the country
query you can scan across the table and do aggregations.

The choice will depend on whether these are batch processed queries or real
time.