|
I would like to know what you think about single vs multiple primary key fields designs.
Sample db design:
Customer - Project - Activity. One customer have many projects. One project have many activities.
Multiple PK design:
Table Activity has threee fields as primary key:
- projectID
- customerID
- activityID
The combination of theese thre are unique. Sample table data
CustID ProjID ActId
1 1 1
1 1 2
1 2 1
2 1 1
Single PK design:
Table Activity has one single unique field as PK:
- ActivityID
Sample table data
CustID ProjID ActId
1 1 1
1 1 2
1 2 3
2 1 4
Project and Customer are referred with foreign keys (which are indexed).
Pro multiple:
I find it easier to track/debug activity data in database.
Cons multiple:
It's more work to create activityID restarting from 1 for each cust/proj combo.
For single PK the pro/cons is the opposite.
What do you think?
Regards,
Micael
Last edited by WGoldwin; 06-11-2009 at 06:11 AM..
|