24 September 2019
Database(13) -- The Entity/Relationship Model
by Jerry Zhang
Entity Sets
An entity is an abstract object of some sort, and a collection of similar entities forms an entity set.
- entity – object
- entity set – class
Attributes
Entity sets have associated attributes, which are properties of the entities in that set.
Relationships
Relationships are connections among two or more entity sets.
Entity-Relationship Diagrams
- Entity sets: rectangles
- Attributes: ovals
- Relationships: diamonds
The arrow pointing to entity set Studios indicates that each movie is owned by at most one studio.
Instances of an E/R Diagram
This set of tuples is called the relationship set for R. However, the “tuples” of a relationship set are not really tuples of a relation, since their components are entites rather than primitive types such as strings or integers.
Multiplicity of Binary E/R Relationships
- If each member of E can be connected by R to at most one member of F, then we say that R is many-one from E to F, and each entity in F can be connected 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.
- If R is neither many-one from E to F or from F to E, then we say R is many-many.
If a relationship is many-one from entity set E to entity set F, then we place an arrow entering F.
- bi-directional arrow: one-one
The arrow means “at most one”, it does not guarantee existence of an entity of the set pointed to.
Multiway Relationships
A relationship Contracts that involves a studio, a star, and a movie.
In multiway relationships, an arrow pointing to an entity set E means that if we select one entity from each of the other entity sets in the relationship, those entities are related to at most one entity in E.
Stars and Movies point to Studios. This indicates that for a particular star and movie, there is only one studio with which the star has contracted for that movie. However, there are no arrows pointing to entity sets Stars or Movies. A studio my contract with several stars for a movie, and a star may contract with one studio for more than one movie.
tags: Database