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
 General SQL Server Forums
 Database Design and Application Architecture
 Database Design

Author  Topic 

paulmajenka
Starting Member

2 Posts

Posted - 2009-06-29 : 13:30:29
I want create a hierarchical table using the primary key as the parentid. Will there be any indexing or performance problems?

Paul_Majenka

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-29 : 13:46:13
how can parentid be primary key? cant there be more than one child for same parent in which case parentid repeats?
Go to Top of Page

paulmajenka
Starting Member

2 Posts

Posted - 2009-06-29 : 14:05:14
Thanks for your reply.

I have written my question poorly. What I meant to say is - If I have a primary key (e.g. id) and then have a 'foreign key' (e.g. parentId) which points to the primary key (id). Are there any issues with this design?

Paul_Majenka
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2009-06-30 : 09:25:21
It's a pretty standard solution so long as you can put a PK<>FK constraint. If I understand correctly though, you are suggesting a row can have itself as a parent. That would be strange and circular and probably cause more problems than it solves.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-06-30 : 10:24:48
No inherent problem with the design.

LoztInSpace makes a good point. Avoid circular reference!


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -