When you define a foreign key you do it as such:
Code:
Foreign Key (attr_1, ... , attr_2) references SomeTable(attr_1 ... , attr_n)
ie you have to explicitly state which table it's referring to.
I don't entirely understand the solution you're proposing. If you have a foreign key in the Humans table identical to the primary key in other tables, how would you get rid of ambiguity when you have the same id in multiple tables? ie Humans(id: 1) can be a reference to Man(id: 1) or Woman(id: 1)
Quote:
Originally Posted by just_grindin
You can also insert the primary key of the humans table as foreign keys in the other tables. That way you can query any table and know exactly which record you're looking for.
This is the best solution I've come up with so far, but seeing as how the primary key for the humans table is (id, gender), it involves adding a gender attribute to the men and womens table which seems ridiculous.
Quote:
Originally Posted by just_grindin
I'd also be curious why you have 2 separate tables for genders.
As opposed to how many?
It's just an abstraction of a homework question that I'm doing. I asked about this first at a q&a platform we have for the class, so I had to try my best to abstract away from the original question to give up as little information as possible. Id is probably a pretty poor choice of identifier because it's intuitively thought of as unique so having the same id multiple times in the humans table looks strange.