High-Level Database Models
The Entity/Relationship Model
Entity sets
Attributes
Relationships
Entity Sets
An
Attributes
Entity sets have associated
Relationships
Entity-Relationship Diagrams
An E/R diagram is a graph representing entity sets, attributes, and relationships.
Entity sets are represented by rectangles
Attributes are represented by ovals
Relationships are represented by diamonds
The Movies entity set has four of our usual attributes: title, year, length, and genre.
Stars-in is a relationship connecting each movie to the stars of that movie. This relationship consequently also connecets starts to the movies in which they appeared.
Owns connects each movie to the studio that owns the movie. The arrow pointing to entity set Studios indicates that each movie is owned by at most one studio.
Multiplicity of Binary E/R Relationships
A binary relationship can connect any member of one of its entity sets to any number of members of the other entity set. Suppose
If each member
can be conncected by to at most one member of , then we say that is many-one from to . Note that in many-one relationship from to , each entity in can be connected by to many members of .If
is both many-one from to and many-one from to , then we say that is one-one. In a one-one relationship an entity of either entity set can be connected to at most one entity of the other set.If
is neither many-one from to or from to , then we say is many-many.
Example
- A one-one realtionship between entity set
and is represented by arrows pointing to both and .
Multiway Relationships
A multiway realtionship in an E/R diagram is represented by lines from the relationship diamond to each of the involved entity sets.
Unified Modeling Language (UML)
UML CLass in UML is similar to an entity set in the E/R model.