Let's assume we have following database:
Or in pseudo sql format (all columns are not null):
create table road (
id int PK
)
create table item_on_road (
id int PK
road_id int FK road.id
position_order int
UNIQUE (road_id, position_order)
)
create table rock (
id int PK FK item_on_road.id
size float
)
// and so on
We have a road
on which we can travel in one direction.
Along the road we can find different things item_on_road
in order we encounter them position_order
like 1,2,3
Things that we find on the road can be different, from sign
to gas_station
.
Now I would like to ask a questions:
Does this database design corresponds to db 1-5th normal forms? I would assume not, because we can create
item_on_road
entry without correspondingrock
If it doesn't corresponds 5th normal form, how to do so?
Optional questions:
If answer to 1 question is yes, how to ensure existence of
rock
ifitem_on_road
created?If answer to 1 question is yes, how to ensure we can't create
rock
andsign
pointing to the same id?