Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Relational Nightmare

Author  Topic 

Onamuji
Aged Yak Warrior

504 Posts

Posted - 2001-07-16 : 14:06:16
First off the old schema:
------------------------------------------------------------
TableA
- Id
- Name

TableB
- Id
- TableA_Id
- Name

TableC
- Id
- TableA_Id
- Other_Data
------------------------------------------------------------
Now the desired schema
------------------------------------------------------------
TableA
- Id
- Name

TableB
- Id
- ParentId
- TableA_Id
- Name

TableC
- Id
- TableA_Id
- Other_Data
------------------------------------------------------------
Small change to get a hierarchical design... however...
TableB.TableA_Id can be included many times... I was doing
a simple set of joins that would create a report of
TableC.Other_Data and group it by TableB.Name and link those
through TableC.TableA_Id and TableA.Id ... and back to
TableB.TableA_Id ... it worked perfectly, but now that
TableB.TableA_Id can be a child of TableB through the
ParentId, I have multiple inclusions of TableC.Other_Data.

Does anyone know how to solve this? I have yet to come up
with a way of including all items from TableB but not
including items that have children.... some items in TableB
will have children items, others will not...

In addition:

Example name hierarchical name content:
Entry A
Entry B
Entry C
- Child Entry A
- Child Entry B
Entry D
Entry E
- Child Entry A
Entry F

Entry C may point to TableA.Id say 5, and the child entry for Entry C, Child Entry A may also point to TableA.Id 5... I don't want to include Entry C at all if it has a child entry taht points to TableA.Id that is the same id as itself....

Hope that makes it a little more clear...

Regards,
Adam

Thanks in advance,
Adam

Edited by - onamuji on 07/16/2001 14:11:16
   

- Advertisement -