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
 New to SQL Server Programming
 When to use Composite Primary Key

Author  Topic 

Abid

110 Posts

Posted - 2014-02-24 : 06:50:30
Hi. I've been facing this situation since long but today i am asking here. Suppose i have a following tables;

AdmissionInfo, AdmID, AdmDate, AdmFee etc.

SubjectInfo i.e. SubID, SubName, SubStatus etc.

The Result table is like this:
ResID, AdmID, SubID, TheoryMarks, PracticalMarks, ObtMarks, TotalMarks, ResultTerm, SubPercentage.

ResID is PK, AdmID and SubID are Foreign Keys, right. Now What i want to ask/ learn that Am i suppose to combine ResID, AdmID and SubID as a composite PK or should i simply make the ResID as PK and other 2 be there as FK? When do we really need to use Composite PK and using it a good thing or not?

maunishq
Yak Posting Veteran

71 Posts

Posted - 2014-02-24 : 12:01:19
When you have more than 1 column as Independent and Unique columns, then you can use Composite PK.
If any value of a column is depending on other column, then you can make it FK.

Just a basic explanation. For deep understanding, use GOOGLE. ;)

!!_(M)_!!
Go to Top of Page
   

- Advertisement -