For example, for cars site.
2 tables, cars and cars_owners.
in cars table, there is a field called carsOwnersID to link the car to its owner.
Here is the problem.
Not every car listed at this site has to have an owner in this project.
So for cars doesn't have the cars owner assigned. How do you set up the carsOwnersID?
I used two approaches before.
1) Create a default record for cars_owners. And every car doesn't have a owner will be assigned the default reocrd as the owner.
2) Set up the carsOwnersID as 0 if the car has no owners, and due to the regualar carsOwenersID will be 1 or up, so if the carsOwnersID is 0, we know the car was not assigned any owners.
This is just example. It could be pets, pet_owners, students, advisors etc.
And both approach has its good or bad points. I have used both base on the projects requirments.
I am trying to see if I can pick 1 of these 2 approaches as my first choice in the future. If I don't have absolute reason, I will stick with the chosed approach. Seems 2) makse more database sense. But in many case, 1) is simple and direct.
Specially for a team project, we need to have a clear standard about which approach we will take.
What you will do, and in what case you will use what approach? Thanks!