Reputation: 621
I'm interested in basic database design. I wanted to design a simple database with states and national parks. Because one state can have many national parks and one national park can be located in many states, I think they should be related as many-to-many.
In this type of relation associative entity is required and this is my design.
I'm not sure about relations between entities and associative entities. I've done it this way, because:
individual state doesn't have to be a location of any national park
one state can be listed with many national parks
therefore, one(optional)-to-many(optional) between "State" and "state_park"
each national park has to be located in at least one state
each national park can be located in many states
therefore, many(optional)-to-one(mandatory) between "state_park" and "State"
I want to know whether my way of thinking is correct or not?
I also want to know what type of data would violate Third Normal Form in my database? I don't think population or area violates this, because it depends on both "id (PK)" and "Name".
Upvotes: 1
Views: 873
Reputation: 4350
As your explanation, I think your first model should be like below (UML Notation):
State
can have 0 or more
(0..*) National Parks
. (optional for state)National Park
can be located in 1 or more
(1..*) State
(s). (mandatory for national park)
And if we map this many-to-many relationship:
National Park
should participate in at least one State_National_Park
. (mandatory for national park)State
can be participate in 0 or more
(0..*) State_National_Park
(s). (optional for state)State_National_Park
(each instance/record that exist in that entity/table) should have one State
and one National Park
.Notice that: cardinality of the optional and mandatory participation are shown in other side of relationships. For example in first model, National Park
has mandatory participation, so in the other side of our model we use 1..*
(not 0..*
).
Also, this model is in 3NF. (However the definition of Area
is ambiguous)
Upvotes: 1