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.
Author |
Topic |
monfu
Yak Posting Veteran
81 Posts |
Posted - 2008-11-05 : 05:51:59
|
Dear AllI have a table Pages and it has the following fieldsPageId smallintPageName nvarchar(250)PageTitle nvarchar(250)fk_buildId intNow normally, how I do it, set the PageId as int and make it the primary key with autoincrement.However, someone suggested to me to put a combined primary key of PageId and fk_BuildId and set the PageId to smallint, and reset to zero whenever the fk_buildId changes. This is done to avoid the PageId being an int.What is the normal standard of doing this? 1 PK with autoincrement or a combination of 2 PK's? I am asking since to keep a comb of 2 PK's requires more work and inserts a little bit of more complexity to it.Thanks for your help and timeJohann |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-05 : 07:42:14
|
quote: Originally posted by monfu Dear AllI have a table Pages and it has the following fieldsPageId smallintPageName nvarchar(250)PageTitle nvarchar(250)fk_buildId intNow normally, how I do it, set the PageId as int and make it the primary key with autoincrement.make it identity column and create primary key constraint on itHowever, someone suggested to me to put a combined primary key of PageId and fk_BuildId and set the PageId to smallint, and reset to zero whenever the fk_buildId changes. This is done to avoid the PageId being an int.didnt understand why you want to include fk into pk. can you explain?What is the normal standard of doing this? 1 PK with autoincrement or a combination of 2 PK's? I am asking since to keep a comb of 2 PK's requires more work and inserts a little bit of more complexity to it. i think former is a better approach unless you've any specific reasonThanks for your help and timeJohann
|
|
|
monfu
Yak Posting Veteran
81 Posts |
Posted - 2008-11-05 : 08:44:16
|
basically I am talking about surrogate and natural keys |
|
|
|
|
|