Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 21st, 2005, 03:23 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default table with multiple children

Hi everyone!!
I have problem while designing the database tables for one of my projects. I have a product database where the products are divided into various categories and subcategories under them. The heirarchy of these categories are such that one category has multiple no. of subcategories under them and correspondingly each of them has multiple child under themselves. This means the tree will be huge with a various branches and roots.

Now I want to avoid this, and reduce the no. of parent & child tables every time a new category or subcategory of products comes up.

How can I do this using the min. no. of tables? Can I do it with only one single table? Each product has a unique ID which is the Primary Field. So how can use the IDs of the categories & subcategories to arrange the in one table so that at the time of retrieval I should not have any problems.

Any body with better idea of database fundamentals and designing will be of great help!!
Thanks in advance
 
Old November 21st, 2005, 07:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

This is a difficult subject, certainly beyond the scope of postings we can do here.

You should obtain the book, "Joe Celko's Trees and Hierarchies in SQL" for a thorough treatment of the subject. You can also look in his book "SQL for Smarties" where he discusses the basic concepts of representing a tree in an SQL database.

You might also try Google for "SQL Nested Sets" and "SQL Adjacency List".

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
insert value into multiple table AzlanAziz SQL Language 5 January 12th, 2007 06:01 AM
Multiple table help dbartelt Access 3 May 31st, 2006 08:15 AM
Table with multiple children arnabghosh SQL Server 2000 1 November 21st, 2005 09:02 AM
Multiple table Query-HELP Kathryn SQL Language 1 March 22nd, 2005 10:57 AM
Multiple Joins in Multiple Table Search query pookster Access 4 September 23rd, 2004 03:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.