0% found this document useful (0 votes)
279 views27 pages

E-R Diagram Design Guide

This document discusses entity-relationship (E-R) diagrams, which allow designers to sketch database schema designs. Key points include: - E-R diagrams represent entities as rectangles, attributes as ovals connected to entities, and relationships as diamonds connecting entity sets. - Relationships have relationship sets that are tuples connecting related entity sets. - Relationships can be many-to-many, many-to-one, or one-to-one depending on how entities are connected. - Multiplicity is shown through arrow directions, with one-side arrows indicating many-to-one relationships and two-side arrows for one-to-one relationships. - Examples demonstrate various relationship types

Uploaded by

Prachi Saxena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
279 views27 pages

E-R Diagram Design Guide

This document discusses entity-relationship (E-R) diagrams, which allow designers to sketch database schema designs. Key points include: - E-R diagrams represent entities as rectangles, attributes as ovals connected to entities, and relationships as diamonds connecting entity sets. - Relationships have relationship sets that are tuples connecting related entity sets. - Relationships can be many-to-many, many-to-one, or one-to-one depending on how entities are connected. - Multiplicity is shown through arrow directions, with one-side arrows indicating many-to-one relationships and two-side arrows for one-to-one relationships. - Examples demonstrate various relationship types

Uploaded by

Prachi Saxena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Department of Computer and Information Science, School of Science, IUPUI

Data Modeling

Entity-Relationship Diagrams
Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu

Dale Roberts

Framework for E-R


Design is a serious business. The boss knows they want a database, but they dont know what they want in it. Sketching the key components is an efficient way to develop a working database.

Dale Roberts

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 entityrelationship diagrams. Later: convert E-R designs to relational DB designs.

Dale Roberts

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.

Dale Roberts

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

Warning!
Graphical representations are inconsistent. Attributes using ovals shall be changed to more of a Class Diagram style later, to save space. The later style insists on singular nouns and uses lines for relationships.

Dale Roberts

Example: Entity
name manf

Beers

Entity set Beers has two attributes, name and manf (manufacturer). Each Beers entity has values for these two attributes, e.g. (Bud, Anheuser-Busch) Underlined attribute(s) is(are) primary key(s)
Dale Roberts
6

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

This relationship has an attribute associated with it.


Dale Roberts
7

Example: Relationships
name addr
Sells

name

manf Bars sell some beers.


Drinkers like some beers. Drinkers frequent some bars.

Bars license Frequents


Note: license = beer, full, none

Beers

Likes

name

Drinkers

addr

Dale Roberts

Relationship Set
The current value of an entity set is the set of entities that belong to it.
Example: the set of all bars in our database.

The value of a relationship is a relationship set, a set of tuples with one component for each related entity set.

Dale Roberts

Example: Relationship Set


For the relationship Sells, we might have a relationship set like:
Bar Joes Bar Joes Bar Sues Bar Sues Bar Sues Bar Beer Bud Miller Bud Petes Ale Bud Lite

Dale Roberts

10

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.

Dale Roberts

11

Example: 3-Way Relationship

3/31/2014

Dale Roberts

12

Example: 3-Way Relationship


name
license Bars Preferences

addr

name
Beers

manf

Drinkers name
Dale Roberts

addr

13

A Typical Relationship Set

Bar Joes Bar Sues Bar Sues Bar Joes Bar Joes Bar Joes Bar Sues Bar

Drinker Ann Ann Ann Bob Bob Cal Cal

Beer Miller Bud Petes Ale Bud Miller Miller Bud Lite

Dale Roberts

14

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.

Dale Roberts

15

In Pictures:

many-many

Dale Roberts

16

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.

Dale Roberts

17

In Pictures:

many-one

Dale Roberts

18

Example: Many-One Relationship


Favorite, from Drinkers to Beers is many-one. A drinker has at most one favorite beer. But a beer can be the favorite of any number of drinkers, including zero.

Dale Roberts

19

Example: Many-One Relationship

Drinkers

Likes

Beers

Favorite

Notice: two relationships connect the same entity sets, but are different.

Dale Roberts

20

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 bestseller (assume no ties).

Dale Roberts

21

In Pictures:

one-one

Dale Roberts

22

Representing Multiplicity
Show a many-one relationship by an arrow entering the one side.
Remember: Like a functional dependency.

Show a one-one relationship by arrows entering both entity sets. Rounded arrow = exactly one, i.e., each entity of the first set is related to exactly one entity of the target set. Pointed arrow = zero or one, i.e., each entity of the first set is related to zero or one entity of the target set. (Optionality)
Dale Roberts
23

Example: One-One Relationship


Consider Best-seller between Manfs and Beers. Some beers are not the best-seller of any manufacturer, so a rounded arrow to Manfs would be inappropriate. But a beer manufacturer has to have a bestseller.

Dale Roberts

24

In the E-R Diagram

Manfs

Bestseller

Beers

A beer is the bestseller for 0 or 1 manufacturer.

A manufacturer has exactly one best seller.

Dale Roberts

25

Modeling Shift

Dale Roberts

26

Acknowledgements
McFadden and Hoffer. Database Management Loney, Kevin. Oracle Database 10g The Complete Reference Ullman, Jeff. Database Systems The Complete Book. DatabaseAnswers.com

3/31/2014

Dale Roberts

27

You might also like