|
Posted by Hugo Kornelis on 05/16/06 23:52
On 16 May 2006 05:34:45 -0700, Robert Ludig wrote:
>I am fairly new to SQL and I am currently trying to create
>a SQL table (using Microsoft SQL) that has a recursive
>relationship, let me try to explain:
>
>I have a piece of Data let's call it "Item" wich may again contain one
>more "Items". Now how would I design a set of SQL Tables that are
>capable of storing this information?
>
>
>I tried the following two approaches:
(snip)
Hi Robert,
I agree with Tom that the first approach is better than the first. But
there are also some radically different ways to store a recursive
relationship or hierarchy. One of the more popular variants is the
nested set model. It's not nearly as intuitive as the model you are
proposing, but it performs far superior in some scenario's.
Google for "Nested Set Model" if you want to know the details.
--
Hugo Kornelis, SQL Server MVP
Navigation:
[Reply to this message]
|