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
 Primary key question

Author  Topic 

nickfinity
Yak Posting Veteran

55 Posts

Posted - 2009-04-08 : 09:44:31
Time for another dumb question. Let's say I've got three tables. Table1 is the primary table. There is a one to many relationship with Table2. Then there is a one to many relationship with Table3 from Table2. The key on Table2 is the key from Table1 plus a sequence number. Does it make more sense to give Table2 a single primary key that is an autonumber that can then be used in Table3? Or should I just repeat the two column key in Table3.

I hope I'm making sense. Thanks for any help, I really appreciate it.

Thanks,
Nick

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2009-04-09 : 07:47:42
If the relationship between Table2 and 3 is a one to many - you could repeat the key - but presumably , you would have to add one column to make the key for Table 3.?

I would avoid using auto generated numbers , unless your programatically generating the auto numbers, via the application workflow

Jack Vamvas
--------------------
http://www.ITjobfeed.com
Go to Top of Page
   

- Advertisement -