How to fetch both Master and detail data from the database

Hi

A few days back I was having a discussion with my colleges on how to fetch data when you want to show category data and also their sub-categories. What I mean is that you have a master table Category (Cat_ID, Cat_Name) and a subcategory table (Subcat_ID, subCat_Name, Cat_ID). Now you want to show category in a gridview and in show the subcategories in the nested grid views inside it.

For this example purpose lets say we have 5 rows in category table and 20 rows in the subcategory table

I know its very simple stuff to be done. But what got into a debate was the fact how to retrieve the data in the best possible way. We had two easy way to fetch data. First was to get all the data from both table and then create a relationship in the Dataset between the tables and bind them. Another way is to use a join in the query and get all the fields from the subcategory table along with the category name from the category table.

[Note: Volume of data means Number of columns * number of rows]

Now when we use the first method we will have to fetch 25 rows from the database (5 rows from the category table and 20 rows from the subcategory table). But the volume of data will be 70(Category (5*2=10) + Subcategory (20 * 3=60)). And the second case we will be retrieving 20 rows only but the volume of data will be 80(20*4=80).

Now you can see that we have pros and cons on both the method. In the first method we are fetching more rows from the database but still the volume of data downloaded is less. While in the second case although the number of rows fetched is less the volume of the data is more.

So which process do you go for while fetching the data from the database?

Hope this helps
Thanks
Vikram


Share this post   Email it |  digg it! |  reddit! |  bookmark it!

Feedback

Posted on 2/6/2007 8:20:37 PM

Hi, thanks for our reply,
could you pls help me about report genaration through vb6.'
and creating remainders.

your reply will greatly helpful to me

Posted on 2/6/2007 9:31:10 PM

Dear Friend,

I want help from you kindly help me

I'm using Excell 2003 & in this application i'm use BAHTTEXT Function but it's display text in Thai Language if you any help to display text in English then Send me suggestion

Thank you

Posted on 2/8/2007 3:17:27 AM

Hi, Can you help me?
i am stuck with a problem,
i need to create a windows client application (webservice) in vb.net which need to intract with the java developed webservice present running in Jboss server..
now this webservice (.Net developed one) should use this jboss as an intermediate one and access the database present in a remote place.

this is my problem can you help me out please

Posted on 2/8/2007 9:40:57 PM

Hi srichand,

I dont Think there should be a problem is accessing the webservise in JBoss server. realistically you can access any webservice(If you have the permission) in which ever server.

Thanks
Vikram

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 
Copyright © 2006 - 2009 Vikram Lakhotia