Conceptual Modeling and Entity-Relationship Diagrams Chapter 3 - - PowerPoint PPT Presentation

conceptual modeling and entity relationship diagrams
SMART_READER_LITE
LIVE PREVIEW

Conceptual Modeling and Entity-Relationship Diagrams Chapter 3 - - PowerPoint PPT Presentation

Conceptual Modeling and Entity-Relationship Diagrams Chapter 3 & 4: Elmasri/Navathe 3753 X1 Outline Phases of Database Design Conceptual Modeling Abstractions in Conceptual Design Example Database Requirements


slide-1
SLIDE 1

3753 X1

Conceptual Modeling and Entity-Relationship Diagrams

Chapter 3 & 4: Elmasri/Navathe

slide-2
SLIDE 2

3753 X1 2

Outline

  • Phases of Database Design
  • Conceptual Modeling
  • Abstractions in Conceptual Design
  • Example Database Requirements
  • Deconstructing the E-R Diagram

– Entities, Attributes and Relationships – Participation, Cardinality and Keys

slide-3
SLIDE 3

3753 X1 3

Phases of Database Design

Requirements Analysis Conceptual Design Data Model Mapping Physical Design Application Domain Database Requirements Conceptual Schema Implementation Schema Physical Schema DBMS Independent DBMS Dependent

slide-4
SLIDE 4

3753 X1

Conceptual Design

  • Similar to the analysis phase in software

development

– produce a description of the data – capture the semantics of the data

  • Description in a high-level model

– close to the user’s view of the world – abstract concepts – means of communication between the user and the developer

4

slide-5
SLIDE 5

3753 X1

Reasons for Conceptual Modeling

  • Independent of DBMS.
  • Allows for easy communication between

end-users and developers.

  • Has a clear method to convert from high-

level model to relational model.

  • Conceptual schema is a permanent

description of the database requirements.

5

slide-6
SLIDE 6

3753 X1 6

Abstractions in Conceptual Design

  • An abstraction is a mental process where

we select some set of properties of an

  • bject and exclude others.
  • 3 types of abstractions

– classification – aggregation – generalization

slide-7
SLIDE 7

3753 X1 7

Classification

  • Define a class of real-world objects with

common properties

Month December February January

slide-8
SLIDE 8

3753 X1 8

Aggregation

  • Define a new class from a set of other

classes that represent component parts

Car Tires Steering Wheel Engine Gas pedal

slide-9
SLIDE 9

3753 X1 9

Generalization

  • Defines a subset relationship between

elements of 2 or more classes

Faculty Staff Employee Person Student

slide-10
SLIDE 10

3753 X1 10

Entity-Relationship Model

  • Most popular conceptual model for

database design

  • Basis for many other models
  • Describes the data in a system and how

that data is related

  • Describes data as entities, attributes

and relationships

slide-11
SLIDE 11

3753 X1 11

Database requirements

  • We must convert the written database

requirements into an E-R diagram

  • Need to determine the entities, attributes

and relationships.

– nouns = entities – adjectives = attributes – verbs = relationships

slide-12
SLIDE 12

3753 X1 12

Acadia Teaching Database

Design an E-R schema for a database to store info about professors, courses and course sections indicating the following:

  • The name and employee ID number of each professor
  • The salary and email address(es) for each professor
  • How long each professor has been at the university
  • The course sections each professor teaches
  • The name, number and topic for each course offered
  • The section and room number for each course section
  • Each course section must have only one professor
  • Each course can have multiple sections
slide-13
SLIDE 13

3753 X1

Name

Visual View of the Database

13

Professor Name First Last Course Employee ID Start Date Years Teaching Room Topic teaches

1 N

Section Section ID Part

  • f

1 N

Number Email Salary

slide-14
SLIDE 14

3753 X1 14

The Pieces

  • Objects

– Entity (including weak entities) – Attribute – Relationship

  • “Structural” Constraints

– Cardinality – Participation

slide-15
SLIDE 15

3753 X1 15

Entities

  • Entity – basic object of the E-R model

– Represents a “thing” with an independent existence – Can exist physically or conceptually

  • a professor, a student, a course
  • Entity type – used to define a set of

entities with the same properties.

slide-16
SLIDE 16

3753 X1 16

Entity and Entity Types

Entity

Number: 3753 Name: Database Management Systems Topic: Introduction to DBMSs

Entity Type

Course Number

Topic

Name

slide-17
SLIDE 17

3753 X1 17

Attributes

  • Each entity has a set of associated properties

that describes the entity. These properties are known as attributes.

  • Attributes can be:

– Simple or Composite – Single or Multi-valued – Stored or Derived – NULL

slide-18
SLIDE 18

3753 X1 18

Attributes (cont’d)

Simple

Professor Start Date

Composite

Professor Name First Last

slide-19
SLIDE 19

3753 X1 19

Attributes (cont’d)

Single

Professor Employee ID#

Multi-Valued

Professor Email

slide-20
SLIDE 20

3753 X1 20

Attributes (cont’d)

Stored

Professor Start Date

Derived

Professor Years Teaching

slide-21
SLIDE 21

3753 X1 21

Attributes (cont’d)

  • NULL attributes have no value

– not 0 (zero) – not a blank string

  • Attributes can be “nullable” where a null

value is allowed, or “not nullable” where they must have a value.

slide-22
SLIDE 22

3753 X1 22

Primary Keys

  • Employee ID is the primary key
  • Primary keys must be unique for the

entity in question

Professor Employee ID

slide-23
SLIDE 23

3753 X1 23

Relationships

  • defines a set of associations between

various entities

  • can have attributes to define them
  • are limited by:

– Participation – Cardinality Ratio

slide-24
SLIDE 24

3753 X1 24

Relationships (cont’d)

Section Course

part of

slide-25
SLIDE 25

3753 X1 25

Participation

  • Defines if the existence of an entity depends on

it being related to another entity with a relationship type.

– Partial – Total

Section Course

part of

slide-26
SLIDE 26

3753 X1 26

Cardinality

  • The number of relationships that an entity

may participate in.

– 1:1, 1:N, N:M, M:1

Section Course

part of

1 N

slide-27
SLIDE 27

3753 X1 27

Weak entity

  • Weak entities do not have key attributes of their
  • wn.
  • Weak entities cannot exist without another a

relationship to another entity.

  • A partial key is the portion of the key that comes

from the weak entity. The rest of the key comes from the other entity in the relationship.

  • Weak entities always have total participation as

they cannot exist without the identifying relationship.

slide-28
SLIDE 28

3753 X1 28

Weak Entity (cont’d)

Section

Course

part of

Number

Section ID

Identifying Relationship

slide-29
SLIDE 29

3753 X1

Review of the ER Diagram

29

Professor Name First Last Course Employee ID Start Date Years Teaching Name Room Topic teaches

1 N

Section Section ID Part

  • f

1 N

Number Email Salary

slide-30
SLIDE 30

3753 X1 30

University DB Case Study

  • Maintain the following information about

undergrad students:

– Name, address, student number, date of birth, year of study, degree program (BA, BSc, BCS), concentration (Major, Honours, etc) and department of concentration.

  • Note: An address is composed of a street, city,

province and postal code; the student number is unique for each student

slide-31
SLIDE 31

3753 X1 31

University Case Study (cont’d)

  • Maintain information about departments

– Name, code (CS, Phy), office phone, and faculty members

  • Maintain information about courses:

– Course number (3753), title, description, prerequisites.

  • Maintain information about course sections:

– Section (A, B, C), term (X1), slot #, instructor

slide-32
SLIDE 32

3753 X1 32

University Case Study (cont’d)

  • Maintain information about faculty:

– Name, rank, employee number, salary, office number, phone number and email address. – Note: employee number is unique

  • Maintain a program of study for the current

year for each student:

– i.e. courses that each student is enrolled in

slide-33
SLIDE 33

3753 X1 33

Extended E-R Model

  • E-R model is sufficient for traditional

database applications

  • Nontraditional applications (CAD,

multimedia) have more complex requirements

  • Can extend traditional E-R diagrams with

semantic data modeling concepts

slide-34
SLIDE 34

3753 X1 34

IS-A Relationship (cont’d)

Employee Staff Faculty Teaching Assistant S.I.N. Student # Rank d Position Name

slide-35
SLIDE 35

3753 X1 35

Specialization & Generalization

  • Specialization

– process of taking an entity and creating several specialized subclasses

  • Generalization

– process of taking several related entities and creating a general superclass

  • We will talk mainly of specialization, but

most information will also apply to generalization

slide-36
SLIDE 36

3753 X1 36

Specialization constraints

  • Specializations can be predicate-defined
  • r attribute-defined (otherwise called user-

defined)

  • Disjointness constraint – specialization is

disjoint or overlapping

  • Completeness constraint – specialization

is total or partial

slide-37
SLIDE 37

3753 X1 37

Predicate-defined subclass

  • An attribute value is used to determine the

members of a subclass

  • Not all members of every subclass can be

determined by the attribute value

  • In the following example, the Pension Plan type

can be used to determine faculty from staff, but has no effect on students or those who opted out

  • f the pension plan.
slide-38
SLIDE 38

3753 X1 38

Predicate-defined subclass

Employee Staff Faculty S.I.N. Rank d Position Pension Plan Type Note: not all employees included

slide-39
SLIDE 39

3753 X1 39

Attribute-defined subclass

  • There is one defining attribute for all

subclasses

  • Each member of the superclass can be

assigned to the appropriate subclass based on this one attribute

slide-40
SLIDE 40

3753 X1 40

Attribute-defined subclass

Employee Staff Faculty S.I.N. Rank d Rank Jobtype Students Year Jobtype “Staff” “Faculty” “Student”

slide-41
SLIDE 41

3753 X1 41

User-defined subclass

  • When there is no condition to

automatically determine membership in a subclass, it must be done at the discretion

  • f the user.
slide-42
SLIDE 42

3753 X1 42

Disjointness constraint

  • Specifies that an entity can be a member
  • f at most one subclass
  • There can be no overlap between the

subclasses

  • We use the notation of a d in a circle to

symbolize that the subclasses are disjoint

slide-43
SLIDE 43

3753 X1 43

Disjoint constraint

Employee Staff Faculty Teaching Assistant S.I.N. Student # Rank d Position Name

slide-44
SLIDE 44

3753 X1 44

Overlap

  • Entities are able to belong to more than
  • ne subclass
  • Notation is an o inside of a circle
slide-45
SLIDE 45

3753 X1 45

Overlap

Employee Staff Faculty S.I.N. Rank

  • Rank

Jobtype Students Year A staff member may also be a student

slide-46
SLIDE 46

3753 X1 46

Completeness Constraint

  • May be total or partial
  • for total, every entity in the superclass

must belong to a subclass

  • for partial, entities in the superclass do not

need to be part of any subclass

  • notation for total and partial are the same

as in a regular E-R diagram – single and double lines

slide-47
SLIDE 47

3753 X1 47

Partial

Employee Staff Faculty S.I.N. Rank

  • Rank

Jobtype Students Year

slide-48
SLIDE 48

3753 X1 48

Total

Employee Staff Faculty S.I.N. Rank

  • Rank

Jobtype Students Year

slide-49
SLIDE 49

3753 X1 49

Hierarchies and Lattices

  • Hierarchies

– a tree-like structure where each subclass belongs to only one superclass – everything we have seen so far is a hierarchy

  • Lattices

– a graph-like structure where a subclass can belong to more than one superclass

slide-50
SLIDE 50

3753 X1 50

Lattice

Person Teaching Assistant Student Employee

  • name

course student # salary