Hi,
I have not very big db. I am using auto increment primary keys and in my case there is no problem with that. GUID is not necessary.
I have a table containing this fields:
- from_destination
- to_testination
- shipper
- quantity
Where the fields 1,2,3 needs to be unique. Also I have second table that for the fields 1,2,3 stores bought quantities per day One to many.
- from_destination
- to_destination
- shipper
- date
- reserved_quantity
case 1 Is it better to make fields 1,2,3 as primary complex key in the first table and the same fields in the second table to be foreign key
First table
from_destination |
to_destination | primary
shipper |
quaititySecond table
second_id - autoincrement primary
from_destination |
to_destination | foreign key
shipper |
date
reserved_quantity
Case 2
or just to add auto increment filed in the first table and make fields 1,2,3 unique. In the second table there will be one ingeger foreign key pointing to the first table, and one auto increment key for the table.
First table
first_id - autoincrement primary
from_destination |
to_destination | unique
shipper |
quaititySecond table
second_id - autoincrement primary
first_id - forein
date
reserved_quantity
If so why we need complex keys, when we can have one field auto increment or GUID and all other fields that are candidates for complex key to be unique.
Regards