My question relates to 0 to many relationships. For example, if you have a customer table and an Order table and a customer can have one or many orders and an order can have zero or one customer. The reason it can have zero is because orders were imported from a legacy order system where customer details where not held.
I believe there are two options:
- Set the CustomerID (foreign ket in Orders table) to null for those orders without a customer.
- Create a junction table between customers and orders containing CustomerID and OrderID. However, I thought junction tables were specifically for many to many relationships
Which is the best alternative?
EDIT:
I have discovered the following post and agree with Molf's answer, which is option 2 in my original question: Any example of a necessary nullable foreign key?.