Create table owner (ownerid int PRIMARY KEY, ownername varchar(50) not null) Create table dog(ownerid int, dogid int, dogname varchar(50), CONSTRAINT pk_col PRIMARY KEY (ownerid, dogid), constraint fk_col foreign key (ownerid) references owner(ownerid) );
This is the best solution you can get. What links the design of the table is that you have a list of owners in the owner table, and the table has only those records where the owner exists in the owner table, which is the parent table, and he has a dog. That only those puppies that have an owner have any entrance to the dog table.
Request to support your requirements.
SELECT owner.ownerid, dog.dogid, dog.dogname FROM owner, dog WHERE owner.ownerid = dog.ownerid
source share