My problem:
Although my database is rather complex I'm just including the car
and customer
tables.
So I have a customer
table with the relevant details and the customer_id
as the primary key
.
Now, within the car
table i want to have a foreign key
linked to the customer_id
, so within the car
table i can see who owns what. The problem is what if the car
hasn't been brought yet?
As far as i can see the foreign key must have a customer_id
to be added to the table.
Am i missing something here or am i way off track, i read something about linked tables?
Can a foreign key
be null
?
One other thing, how do i set up rules like:
'A car
can only have 1 manufacturer
(which is a separate table linked with a fk
)'? I'm guessing that's done with php correct?
If anyone wants a pic of the databases current ERD, i have one.