In MySQL, is it bad to have a table structure like the following…
Table stuffA
ID
Table stuffB
ID
Table superStuff
ID
type
stuffID
…where depending on the value of superStuff(type), superStuff(stuffID) could reference either stuffA(ID) or stuffB(ID) ?
Thanks, in advance, for your help
I think you mean the other way around:
Besides you don’t need the
typeattribute because it is implicit when you query one table or the other.NOTE: I’m assuming you also have other fields on the tables and that you’ve ommited them in order to make a minimal example. If this is not the case, probably you wouldn’t need a hierachy there.
This answer might be helpful in understanding this.