Docsity

Entity-Relationship Model: Understanding Entity Sets, Relationships, and Weak Entity Sets, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Entity-Relationship Model: Understanding Entity Sets, Relationships, and Weak Entity Sets and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Entity-Relationship Model

E/R Diagrams Weak Entity Sets

Converting E/R Diagrams to Relations

Purpose of E/R Model

  • The E/R model allows us to sketch database schema designs. - Includes some constraints, but not operations.
  • Designs are pictures called entity- relationship diagrams.
  • Later: convert E/R designs to relational DB designs.

Entity Sets

  • Entity = “thing” or object.
  • Entity set = collection of similar entities.
    • Similar to a class in object-oriented languages.
  • Attribute = property of (the entities of) an entity set. - Attributes are simple values, e.g. integers or character strings, not structs, sets, etc.

E/R Diagrams

  • In an entity-relationship diagram:
    • Entity set = rectangle.
    • Attribute = oval, with a line to the rectangle representing its entity set.

Relationships

  • A relationship connects two or more entity sets.
  • It is represented by a diamond, with lines to each of the entity sets involved.

Example: Relationships

8

name^ Drinkers^ addr

Beers

name manf

Bars

name

license

addr

Note: license = beer, full, none

Sells Bars sell some beers.

Likes

Drinkers like Frequents some beers. Drinkers frequent some bars.

Example: Relationship Set

  • For the relationship Sells, we might have a relationship set like:

10

Bar Beer Joe’s Bar Bud Joe’s Bar Miller Sue’s Bar Bud Sue’s Bar Pete’s Ale Sue’s Bar Bud Lite

Multiway Relationships

  • Sometimes, we need a relationship that connects more than two entity sets.
  • Suppose that drinkers will only drink certain beers at certain bars. - Our three binary relationships Likes, Sells, and Frequents do not allow us to make this distinction. - But a 3-way relationship would.

A Typical Relationship Set

13

Bar Drinker Beer Joe’s Bar Ann Miller Sue’s Bar Ann Bud Sue’s Bar Ann Pete’s Ale Joe’s Bar Bob Bud Joe’s Bar Bob Miller Joe’s Bar Cal Miller Sue’s Bar Cal Bud Lite

Many-Many Relationships

  • Focus: binary relationships, such as Sells between Bars and Beers.
  • In a many-many relationship, an entity of either set can be connected to many entities of the other set. - E.g., a bar sells many beers; a beer is sold by many bars.

Many-One Relationships

  • Some binary relationships are many - one from one entity set to another.
  • Each entity of the first set is connected to at most one entity of the second set.
  • But an entity of the second set can be connected to zero, one, or many entities of the first set.

In Pictures:

17

many-one

One-One Relationships

  • In a one-one relationship, each entity of either entity set is related to at most one entity of the other set.
  • Example: Relationship Best-seller between entity sets Manfs (manufacturer) and Beers. - A beer cannot be made by more than one manufacturer, and no manufacturer can have more than one best-seller (assume no ties).

In Pictures:

20

one-one