I
Ilan Sebba
I have a 'child' table (say Substance), which can be made out of one of
three 'parent' tables (Animal, Vegetable or Mineral). The uniqueness of
each substance record is determined by the parent record, and by the time
the substance was created. So I would like to have a composite key made out
of Animal, Vegetable or Mineral, and the time stamp.
tblAnimal
ID
AnimalFields
tblVegetable
ID
VeggieFields
tblMineral
ID
MineralFields
tlbSubstance
AnimalVegetableOrMinaral [PK1]
TimeStamp [PK2]
SubstanceFields
My problem is the field Animal, Vegetable or Mineral. This is supposed to
be a foreign key. But to which table? How do I do this. One way, which
will guarantee two voids in each record, is this:
tblSubstance
AnimalFK [PK1]
VegetableFK [PK2]
MineralFK [PK3]
TimeStamp [PK4]
SubstanceFields
Given that a substance has only one parent (animal, vegetable or mineral),
there will always be two voids. I don't like voids (I am sure 'void' and
'avoid' are related).
Another solution is to create a dummy 'grandparent' table which will be a
parent to all animals, vegetables or minerals, and then require that have a
1-2-1 relationship between this dummy table and Animal, Vegetable and
Mineral.
tblCreator
ID
tblAnimal
CreatorFK [PK]
AnimalFields
tblVegetable
CreatorFK [PK]
VeggieFields
tblMineral
CreatorFK
MineralFields
Now my substance table can have one a two field composite key of CreatorID
and Timestamp.
tblSubstance
CreatorID
Timestamp
SubstanceFields
OK, so this is a solution. But I don't like it. It involves creating a
truly dummy field which serve no purpose other than helping me avoid my
dislikes. Do two wrongs make a right?
So, what would the TableDesign newsgroup recommend I do?
Any suggestions most appreciated.
three 'parent' tables (Animal, Vegetable or Mineral). The uniqueness of
each substance record is determined by the parent record, and by the time
the substance was created. So I would like to have a composite key made out
of Animal, Vegetable or Mineral, and the time stamp.
tblAnimal
ID
AnimalFields
tblVegetable
ID
VeggieFields
tblMineral
ID
MineralFields
tlbSubstance
AnimalVegetableOrMinaral [PK1]
TimeStamp [PK2]
SubstanceFields
My problem is the field Animal, Vegetable or Mineral. This is supposed to
be a foreign key. But to which table? How do I do this. One way, which
will guarantee two voids in each record, is this:
tblSubstance
AnimalFK [PK1]
VegetableFK [PK2]
MineralFK [PK3]
TimeStamp [PK4]
SubstanceFields
Given that a substance has only one parent (animal, vegetable or mineral),
there will always be two voids. I don't like voids (I am sure 'void' and
'avoid' are related).
Another solution is to create a dummy 'grandparent' table which will be a
parent to all animals, vegetables or minerals, and then require that have a
1-2-1 relationship between this dummy table and Animal, Vegetable and
Mineral.
tblCreator
ID
tblAnimal
CreatorFK [PK]
AnimalFields
tblVegetable
CreatorFK [PK]
VeggieFields
tblMineral
CreatorFK
MineralFields
Now my substance table can have one a two field composite key of CreatorID
and Timestamp.
tblSubstance
CreatorID
Timestamp
SubstanceFields
OK, so this is a solution. But I don't like it. It involves creating a
truly dummy field which serve no purpose other than helping me avoid my
dislikes. Do two wrongs make a right?
So, what would the TableDesign newsgroup recommend I do?
Any suggestions most appreciated.