SQL PrimaryKey best practice

I am creating a table ProjectSites that will be a child table to another table Projects and it will only have three columns, here is the current schema

ProjectSites Table:

ProjectSiteID          identity  pk
ProjectID                int          fk
SiteID                     int          fk

So the idea is, there can be one or more Sites assigned to every project. There will never be a case where the same Site is assigned more than once to the same Project. My question is this, Should I make the PK of the table a combination of all three columns so that no mistakes can ever be made?
LVL 6
AkAlanAsked:
Who is Participating?
 
Asim NazirCommented:
You can also Add Unique constraint to two of the fields i.e. other than one PK field.
0
 
Paul JacksonSoftware EngineerCommented:
Yes that's the only way to meet all your conditions.
0
 
AkAlanAuthor Commented:
Ok, I thought that was so, I was just thinking about any performance issues that could cause. Thanks.
0
 
Paul JacksonSoftware EngineerCommented:
Will it impact performance? yes but  marginally given they are int columns. It is unavoidable given the requirements specified and best practice
0
 
AkAlanAuthor Commented:
Thanks to both.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.