How to 'normalise' this scenario
From: Frank Millman <frank_at_chagford.com>
Date: Fri, 13 May 2011 00:22:38 -0700 (PDT)
Message-ID: <aa6465c6-b0d8-4bd1-86f7-a90b07326d58_at_v10g2000yqn.googlegroups.com>
Hi all
Date: Fri, 13 May 2011 00:22:38 -0700 (PDT)
Message-ID: <aa6465c6-b0d8-4bd1-86f7-a90b07326d58_at_v10g2000yqn.googlegroups.com>
Hi all
I have read up on 'nested sets', and I like the concept.
It seems to me that there are (at least) two possible scenarios -
- The table *is* the data - e.g. staff members in a hierarchy.
- The table is used as navigation for a separate data table. For example, you might have thousands of product codes, and you want to set up a separate table to provide a hierarchical 'view' of the product code table, allowing a user to drill down to find the code they are looking for.
A 'branch' node may require columns for 'code' and 'description'.
A 'leaf' node requires a column that contains a foreign key to the products table.
It is tricky to ensure that there is one, and only one, 'leaf' node
for each row in the product table.
It is tricky to ensure that 'branch' codes are unique, as 'leaf' nodes
will have a null 'code', and MS SQL Server does not allow more than
Is there an approach that satisfies the requirement, but avoids these problems?
Thanks for any insights.
Frank Millman Received on Fri May 13 2011 - 09:22:38 CEST