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
 Should I always have a PK?

Author  Topic 

kpgraci
Yak Posting Veteran

68 Posts

Posted - 2011-10-13 : 12:30:35
I have some tables that relate one table to another, so they consist of only two fields, both FK's from the two parent tables.

Also I have tables that hold a subset of data, for example I'll have a client table, and then if that client is a person I will have extra data about the client in a clientinfo table, if a business a businessinfo table - both of these sub-tables have only a FK of the main table.

In these cases, is it good design to have an autoincrement PK ID field in these tables? It will never be used but it seems odd to not have a PK.




kpg

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-13 : 12:34:13
you can either have an autoincrement pk or you may choose composite combination of id fields as the PK

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

human12
Starting Member

5 Posts

Posted - 2011-10-27 : 07:32:10
The two fields are unique and they should be, otherwise u have design issues, so u create a composite key
if by design and due to something urgent, they are not unique, then u can introduce increment to be your PK



Tarek Omar
Technical Manager and Database Administrator
http://intosql.blogspot.com
Go to Top of Page
   

- Advertisement -