ER Design (2) What Can We Do? We Already Know How to Model Roles - - PDF document

er design 2 what can we do
SMART_READER_LITE
LIVE PREVIEW

ER Design (2) What Can We Do? We Already Know How to Model Roles - - PDF document

ER Design (2) What Can We Do? We Already Know How to Model Roles Cardinality constraints Participation Choice of entity sets attributes, or relationship sets Binary and non-binary relationships However, there are


slide-1
SLIDE 1

ER Design (2)

slide-2
SLIDE 2

CMPT 354: Database I -- ER Design (2) 2

What Can We Do?

  • We Already Know How to Model

– Roles – Cardinality constraints – Participation – Choice of entity sets attributes, or relationship sets – Binary and non-binary relationships

  • However, there are more complicated

situations …

slide-3
SLIDE 3

CMPT 354: Database I -- ER Design (2) 3

Translating Constraints

  • Translating all constraints may not be

possible – there may be instances in the translated schema that cannot correspond to any instance of R

– Many-to-one from A and B to C cannot be translated if the ternary relationship is converted into 3 binary ones

A B C A B C

slide-4
SLIDE 4

CMPT 354: Database I -- ER Design (2) 4

Mapping Cardinalities Affects Design

  • We can make access-date an attribute of account, instead
  • f a relationship attribute, if each account can have only
  • ne customer

– Then, the relationship from account to customer is many to one, or equivalently, customer to account is one to many

slide-5
SLIDE 5

CMPT 354: Database I -- ER Design (2) 5

Weak Entity Sets

  • An entity set that does not have a primary

key

– The existence of a weak entity set depends on the existence of an identifying entity set

slide-6
SLIDE 6

CMPT 354: Database I -- ER Design (2) 6

Weak Entity Sets (Cont.)

  • A weak entity set must relate to the identifying

entity set via a total, one-to-many relationship set from the identifying relationship set to the weak entity set

– The identifying relationship set depicted using a double diamond

  • The discriminator (or partial key) of a weak entity

set is the set of attributes that distinguishes among all the entities of a weak entity set

  • The primary key of a weak entity set is formed by

the primary key of the strong entity set on which the weak entity set is existence dependent, plus the discriminator of the weak entity set

slide-7
SLIDE 7

CMPT 354: Database I -- ER Design (2) 7

One More Example

  • In a university, a course is a strong entity

and a course_offering can be modeled as a weak entity

– The discriminator of course_offering would be semester (including year) and section_number (if there is more than one section)

  • How to draw the ER diagram?
slide-8
SLIDE 8

CMPT 354: Database I -- ER Design (2) 8

Sub-Classes and ISA Relationships

slide-9
SLIDE 9

CMPT 354: Database I -- ER Design (2) 9

Aggregation: Motivation

  • Consider the ternary relationship works_on, which

we saw earlier. Suppose we want to record managers for tasks performed by an employee at a branch

slide-10
SLIDE 10

CMPT 354: Database I -- ER Design (2) 10

Aggregation

  • Relationship sets works_on and manages

represent overlapping information

– Every manages relationship corresponds to a works_on relationship – However, some works_on relationships may not correspond to any manages relationships

  • So we can’t discard the works_on relationship
  • Eliminate this redundancy via aggregation

– Treat relationship as an abstract entity – Allows relationships between relationships – Abstraction of relationship into new entity

slide-11
SLIDE 11

CMPT 354: Database I -- ER Design (2) 11

E-R Diagram with Aggregation

slide-12
SLIDE 12

CMPT 354: Database I -- ER Design (2) 12

Case Study – Student Info Sys

  • Basic entities

– Students: name, address, department – Courses: department, title, description – Instructor: name, rank, office

student course instructor name address department title description department name rank

  • ffice
slide-13
SLIDE 13

CMPT 354: Database I -- ER Design (2) 13

Relationships

  • Students take courses
  • Instructors teach courses

student course instructor name address department title description department name rank

  • ffice

take-course semester classroom teach time semester classroom time

slide-14
SLIDE 14

CMPT 354: Database I -- ER Design (2) 14

Problem: Missing Entities

  • Course offering is missing

– Repeated information: semester, classroom, time – Missing constraint: each class has one instructor

student course instructor name address department title description department name rank

  • ffice
  • ffering

semester classroom take-course time session teach

slide-15
SLIDE 15

CMPT 354: Database I -- ER Design (2) 15

Adding Information

  • More information about departments should be kept

– Name, location, chair

student course instructor name address title description name rank

  • ffice
  • ffering

semester classroom take-course time session teach department name location chair member-of major home-dept

slide-16
SLIDE 16

CMPT 354: Database I -- ER Design (2) 16

Using Classes

  • Current students and alumni

current_student course instructor title description name rank

  • ffice
  • ffering

semester classroom take-course time session teach department name location chair member-of major home-dept alumni graduate student name address isa

slide-17
SLIDE 17

CMPT 354: Database I -- ER Design (2) 17

UML

  • UML: Unified Modeling Language
  • UML has many components to graphically

model different aspects of an entire software system

  • UML Class Diagrams correspond to E-R

Diagram, but several differences

slide-18
SLIDE 18

CMPT 354: Database I -- ER Design (2) 18

UML Class Diagram Notation

slide-19
SLIDE 19

CMPT 354: Database I -- ER Design (2) 19

Summary

  • Model real world data using entities and

relationships

  • The ER model
  • ER diagrams

– Entities, relationships, attributes – Constraints, keys, cardinalities – Weak entities

slide-20
SLIDE 20

CMPT 354: Database I -- ER Design (2) 20

To-Do List

  • Read Chapter 6 (except for Section 6.9)
  • Draw the ER diagram for the Mini_TPC

database