High-Level Database Models
The Entity/Relationship Model
Entity sets
Attributes
Relationships
Entity Sets
An \(\text{entity}\) is an abstract object of some sort, and a collection of similar entities forms an entity set.
Attributes
Entity sets have associated \(\text{attributes}\), which are properties of the entities in tha set.
Relationships
\(\text{Relationships}\) are connections among two or more entity sets.
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 \(R\) is a relationship connecting entity sets \(E\) and \(F\). Then:
If each member \(E\) can be conncected by \(R\) to at most one member of \(F\), then we say that \(R\) is many-one from \(E\) to \(F\). Note that in many-one relationship from \(E\) to \(F\), each entity in \(F\) can be connected by to many members of \(E\).
If \(R\) is both many-one from \(E\) to \(F\) and many-one from \(F\) to \(E\), then we say that \(R\) 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 \(R\) is neither many-one from \(E\) to \(F\) or from \(F\) to \(E\), then we say \(R\) is many-many.
Example
- A one-one realtionship between entity set \(E\) and \(F\) is represented by arrows pointing to both \(E\) and \(F\).
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.