Return-Path: Delivered-To: apmail-hbase-user-archive@www.apache.org Received: (qmail 95597 invoked from network); 22 Aug 2010 10:57:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Aug 2010 10:57:05 -0000 Received: (qmail 75908 invoked by uid 500); 22 Aug 2010 10:57:04 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 75748 invoked by uid 500); 22 Aug 2010 10:57:01 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 75740 invoked by uid 99); 22 Aug 2010 10:57:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Aug 2010 10:57:00 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of shujamughal@gmail.com designates 74.125.82.169 as permitted sender) Received: from [74.125.82.169] (HELO mail-wy0-f169.google.com) (74.125.82.169) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Aug 2010 10:56:56 +0000 Received: by wyg36 with SMTP id 36so6380149wyg.14 for ; Sun, 22 Aug 2010 03:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=MAC4dQy1OlI66tEO4A/0KkK6C/zDxLSOV+QaNGXMGlY=; b=kkoyOruIRuxEvvnjmTu/5/xT9/CifnUhQf+zDJzdAOdofkJPFV9UPqWcevSsRkJp+3 DUulHRcmBwqsETYbXG4YmM7nmIAJRTIIv5JzBeD7AYQkORrn2ELjP6HpTrJBZvYvmVd5 Ayg23QODp06Qh3qcM4Ggk5+79CLfp/UgFkpWI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=kcsj7PsfJqrjP4eYV+ckN1cRPjIvelbMLPsTd/AzW3D9XOJqFAHILZzsv+8zmMPZmV +ujzl1ghhFUc+W1ihSdEiUkQB6NaS2xNcgtvDmj4hRfwNdX8QVrYyOeZeIjxvgVyNZHx 5zDY7lUsXy+LdFJBiIpMRwyPBk1qeWglYRG+U= MIME-Version: 1.0 Received: by 10.216.52.135 with SMTP id e7mr3206507wec.98.1282474593911; Sun, 22 Aug 2010 03:56:33 -0700 (PDT) Received: by 10.216.12.14 with HTTP; Sun, 22 Aug 2010 03:56:33 -0700 (PDT) In-Reply-To: References: Date: Sun, 22 Aug 2010 15:56:33 +0500 Message-ID: Subject: Re: How to Map One to Many relations on HBase? From: Shuja Rehman To: user@hbase.apache.org Content-Type: multipart/alternative; boundary=0016e6de181c9a82e9048e676287 --0016e6de181c9a82e9048e676287 Content-Type: text/plain; charset=ISO-8859-1 Thanks ryan and imran for answering. As ryan mentioned, i can put children into row of parent. its fine if i have one parent and then children but here in my case children then will act as parent and has more children like BaseCategory-> category-> Product so if i create one table for all then the structure might look like this. *Row Key* *Column Families* * * Base Category ID BaseCategoryInfo: CategoriesInfo: ProductInfo: Base Category Info:Name Base Category Info:Description Categories:catName ProductInfo:Name 1 Drink Soft Hard AbcDrik XyzDrink But in this structure the problem is between Category and Product. e.g I can say soft and hard are children of drink but what about AbcDrink and XyzDrink who are the parents of these soft or hard? What do you think about it? Thanks On Sat, Aug 21, 2010 at 8:55 AM, Imran M Yousuf wrote: > Hi! > > On Fri, Aug 20, 2010 at 5:46 PM, Shuja Rehman > 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 > -- Regards Shuja-ur-Rehman Baig http://pk.linkedin.com/in/shujamughal Cell: +92 3214207445 --0016e6de181c9a82e9048e676287--