I have a little question regarding how I should create my database. I have table dogs for an animal shelter, and I have table owners. On the dog’s table, all the dogs that were and were once in the shelter are placed. Now I want to establish a relationship between table dogs and table owners.
The problem is that in this example not all dogs have an owner, and since the owner can have more than one dog, a possible foreign key must be placed in table dogs (the dog cannot have more than one owner, at least not in the shelter ) But if I do, some dogs (those that are in the shelter) will have zero as a foreign key. Reading some other topics taught me that this is allowed. (Or maybe I read a few wrong topics)
However, another possibility is to put a table between two tables — for example, “dog owners” —and place the primary key of both tables there if the dog has an owner.
Now my question is (as you might have guessed) what is the best method of these two and why?
source
share