I have a database that looks something like this:
Table: Creature
Fields, CreatureId {PK}, ...
Table: Bug
Fields: BugId {PK}, CreatureId {FK}...
Table: LadyBird
Fields: LadyBirdId {PK}, BugId {FK}...
Every creature in the system is in the Creature-table. If the creature
also is a bug, then it's also in the bug table. And if it's a
LadyBird, it's also in the LadyBird-table.
A problem with the current design is that several bugs could be of the
same creature, and several LadyBirds could be of the same bug which
should not be possible.
So I'm thinking about removing the fields BugId and LadyBirdId, and
use CreatureId (as primary key) instead in the bug and ladybird table.
Would that improve the design of the database? With a new design it's
possible to have a LadyBird that's not a Bug.
I still thinks the new design would be better, but I'm gladly accept
advices before I starts the redesign (which will be quite some work to
do :-/ )
PEK
							
						
					Table: Creature
Fields, CreatureId {PK}, ...
Table: Bug
Fields: BugId {PK}, CreatureId {FK}...
Table: LadyBird
Fields: LadyBirdId {PK}, BugId {FK}...
Every creature in the system is in the Creature-table. If the creature
also is a bug, then it's also in the bug table. And if it's a
LadyBird, it's also in the LadyBird-table.
A problem with the current design is that several bugs could be of the
same creature, and several LadyBirds could be of the same bug which
should not be possible.
So I'm thinking about removing the fields BugId and LadyBirdId, and
use CreatureId (as primary key) instead in the bug and ladybird table.
Would that improve the design of the database? With a new design it's
possible to have a LadyBird that's not a Bug.
I still thinks the new design would be better, but I'm gladly accept
advices before I starts the redesign (which will be quite some work to
do :-/ )
PEK
 
	
Comment