You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by monty123 <ma...@yahoo.com> on 2009/06/10 09:56:18 UTC

fetch data in 1-n relationship

Hi All

I define two tables having one to many relationship:

Student:
    student id
    student data (name, address, ...)
    courses  (use course ids as column qualifiers here)

Course:
   course id
   course data (name, syllabus, ...)

My problem is, using Java client/program how to fetch courses ID from
student table 
coz they are stored like ( courses:2001 ) and course id is (2001), I am
confused :(
and whether I need to perform another query to fetch details of courses
table.(to simulate join in rdbms)

-- 
View this message in context: http://www.nabble.com/fetch-data-in-1-n-relationship-tp23957512p23957512.html
Sent from the HBase User mailing list archive at Nabble.com.


Re: fetch data in 1-n relationship

Posted by "Ryan J. McDonough" <ry...@damnhandy.com>.
But of course, with this solution, your application code must be  
responsible for synchronizing the course data in the student table -  
for each student. This could become an expensive operation if you have  
to update or delete a course if a large number of students are  
enrolled in a given class.

Ryan-


On Jun 10, 2009, at 11:41 PM, Jean-Daniel Cryans wrote:

> monty,
>
> 2 things you can do:
>
> 1- Serialize courses data into the courses family in the student
> table. You duplicate data, but disk is cheap so that's ok now.
>
> 2- If all you need is to first show the course id and the course title
> (or description), you can just put that as the value in the courses
> family and do the get on the courses table only if you need to.
>
> J-D
>
> On Wed, Jun 10, 2009 at 12:56 AM, monty123<ma...@yahoo.com>  
> wrote:
>>
>> Hi All
>>
>> I define two tables having one to many relationship:
>>
>> Student:
>>    student id
>>    student data (name, address, ...)
>>    courses  (use course ids as column qualifiers here)
>>
>> Course:
>>   course id
>>   course data (name, syllabus, ...)
>>
>> My problem is, using Java client/program how to fetch courses ID from
>> student table
>> coz they are stored like ( courses:2001 ) and course id is (2001),  
>> I am
>> confused :(
>> and whether I need to perform another query to fetch details of  
>> courses
>> table.(to simulate join in rdbms)
>>
>> --
>> View this message in context: http://www.nabble.com/fetch-data-in-1-n-relationship-tp23957512p23957512.html
>> Sent from the HBase User mailing list archive at Nabble.com.
>>
>>


Re: fetch data in 1-n relationship

Posted by Jean-Daniel Cryans <jd...@apache.org>.
monty,

2 things you can do:

1- Serialize courses data into the courses family in the student
table. You duplicate data, but disk is cheap so that's ok now.

2- If all you need is to first show the course id and the course title
(or description), you can just put that as the value in the courses
family and do the get on the courses table only if you need to.

J-D

On Wed, Jun 10, 2009 at 12:56 AM, monty123<ma...@yahoo.com> wrote:
>
> Hi All
>
> I define two tables having one to many relationship:
>
> Student:
>    student id
>    student data (name, address, ...)
>    courses  (use course ids as column qualifiers here)
>
> Course:
>   course id
>   course data (name, syllabus, ...)
>
> My problem is, using Java client/program how to fetch courses ID from
> student table
> coz they are stored like ( courses:2001 ) and course id is (2001), I am
> confused :(
> and whether I need to perform another query to fetch details of courses
> table.(to simulate join in rdbms)
>
> --
> View this message in context: http://www.nabble.com/fetch-data-in-1-n-relationship-tp23957512p23957512.html
> Sent from the HBase User mailing list archive at Nabble.com.
>
>