0% found this document useful (0 votes)
8 views60 pages

Chapter 5

Chapter 5 of 'Database Systems: Design Implementation and Management' focuses on Entity Relationship (ER) Modelling, detailing the characteristics of the ER model, the development of ER diagrams, and the reconciliation of conflicting goals in database design. Key concepts include entities, attributes, relationships, and the importance of primary keys, as well as the iterative process of creating an ERD. The chapter also discusses various types of attributes and relationships, including weak entities and the steps involved in developing an ER diagram.

Uploaded by

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

Chapter 5

Chapter 5 of 'Database Systems: Design Implementation and Management' focuses on Entity Relationship (ER) Modelling, detailing the characteristics of the ER model, the development of ER diagrams, and the reconciliation of conflicting goals in database design. Key concepts include entities, attributes, relationships, and the importance of primary keys, as well as the iterative process of creating an ERD. The chapter also discusses various types of attributes and relationships, including weak entities and the steps involved in developing an ER diagram.

Uploaded by

h49zd4kxps
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

DATABASE SYSTEMS

DESIGN IMPLEMENTATION AND MANAGEMENT

INTERNATIONAL EDITION

ROB • CORONEL • CROCKETT

Chapter 5
Entity Relationship (ER) Modelling
1
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

In this chapter, you will learn:


A. The main characteristics of the entity relationship model
B. The processes involved in developing an ER diagram
C. That real-world database design often requires the
reconciliation of conflicting goals

Watch the next video


https://www.youtube.com/watch?v=IfaqkiHpIjo

2
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Announcements

• Practical 1 to be run next week on 6 March 25,


on Blackboard between 0900 and 0930

3
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

A. The Entity Relationship (ER) Model


• We have dealt with some of the basic concepts of
the ER model in previous lectures. Some key
points are:
– ER model forms the basis of an ER diagram (ERD)
– ERD represents conceptual database as viewed by end
user
– ERDs depict database’s main components:
• Entities
• Attributes
• Relationships
4
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

ER Model
• Attribute – characteristics of entities
– E.g. student – STU_LNAME, STU_FNAME, STU_E-
MAIL
– Required attributes – cannot be left empty

• Domain - set of possible values for a given


attribute
– E.g. gender can be M or F

5
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Entities
• In UML notation, an entity is represented by a box
that is subdivided into three parts:
– Top: Entity name, a noun, is usually written in capital letters
– Middle part: for attributes
– Bottom part: for methods

6
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Keys

7
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Relational schema
Coronel & Crockett 9781844807321)

• CAR (CAR_REG, MOD_CODE, CAR_YEAR,


CAR_COLOUR

CAR

CAR_REG MOD_CODE CAR_YEAR CAR_COLOUR

8
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Relational schema
Coronel & Crockett 9781844807321)

• A textual representation of database tables, where


each table is described by its name followed by a list
of its attributes in parenthesis
– R = {a1 , a2 , a3 …. an}
– Student (Stud_Num, FirstName, Surname, Age)

Student

Stud_Num FirstName Surname Age

9
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Primary Keys
• PKs are underlined in the ERD
• PK attributes are also underlined in the
relational schema
– A relational schema is a textual representation of the
database tables, where each table is described by its
name followed by the list of its attributes in
parentheses
– For example, a CAR entity may be represented by:
CAR (CAR_REG, MOD_CODE, CAR_YEAR,
CAR_COLOUR)
10
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Composite Primary Keys


• Primary keys are ideally composed of only a single
attribute
• Possible to use a composite key
– Primary key composed of more than one attribute

11
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

12
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Exercise on ER modeling
• Draw an entity-relationship diagram showing the following:
– A BOOK entity with the attributes of ISBN, book title, and data
published. Choose a PK.
– A RECIPE entity with the attributes of a recipe number, recipe name,
cooking time and oven setting
– The business rule describing the relationship between them is that a
book contains one or many recipes, but each recipe only appears in one
book.
– There is also an INGREDIENT table with the attributes of ingredient
number and ingredient name.
– Business rule: A recipe can have many ingredients and a particular
ingredient can be found in many recipes. How will RECIPE and
INGREDIENT be related?

13
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Steps to include a Bridging entity

• Identify the many-to-many relationship (*…*)


• Insert the bridging entity
• Name the bridging entity using the original entities’ names
• Duplicate the PK of both original entities to the bridging entity
(indicate as FK)
• Assign both the FK as the PK in the bridging entity (indicate in PK)
• Assign the relationships between bridging entity and two original
entities, the 1..1 relationship closest to the original entity.
• Delete the original *…* relationship

14
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

A Recipe ERD

1…*

1…*

15
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Attributes

16
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Composite and Simple Attributes


• Composite attributes
can be subdivided to yield
further attributes
– eg address

17
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Composite and Simple Attributes

• Simple attribute cannot be subdivided further


– eg age

• Simple attributes are atomic values, which


cannot be divided further. For example, a
student's phone number is an atomic value of 10
digits

18
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Single and Multi-Valued Attributes

• Single-value attribute can have only a single value


– Eg one ID number
– But it can be a composite attribute e.g. BYD201EC

• Multi-valued attributes can have many values


– Eg degree. A person can have more than one degree

19
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Derived Attributes
• Attribute whose value may be calculated (derived) from other
attributes
• Need not be physically stored within database
• Can be derived by using an algorithm
– An 'algorithm' is an effective method for solving a problem expressed as a
finite sequence of instructions. Algorithms are used for calculation, data
processing, and many other fields (Wikipedia, 28 Jul 2010).
• Depicted with a ‘/’ before the attribute name

20
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Derived Attributes example

21
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Derived Attributes –
to store or not to store?

22
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Relationships

23
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Relationships
• Association between entities
• Entities in a relationship are also know as participants
• Relationships between entities always operate in both
directions
– A CUSTOMER may generate many INVOICEs
– Each INVOICE is generated by one CUSTOMER
– Each relationship can be classified as 1:*
– But might be part of a *:* relationship

• Relationship classification is difficult to establish if


know only one side of the relationship
24
Relationship Degree
• Indicates number of entities or participants
associated with a relationship
• Unary relationship (Degree 1)
– Association is maintained within single entity
• Binary relationship (Degree 2)
– Two entities are associated
• Ternary relationship (Degree 3)
– Three entities are associated
• Higher degrees exist, but are rare, e.g. four-
degree
Relationship Degree – example

Ternary Relationship

Source: Rob, Coronel & Crockett


(2009) – Amended by JteB
Recursive\Unary Relationships
• Relationship can exist between occurrences of
the same entity set
• Naturally found within unary relationship
Recursive Relationships - examples
Recursive Relationships – using one
table
Relationships: Degree
Entity1 Entity3
TernaryRelationship

Entity2

30
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Different Relationship concepts


• Multiplicity refers to the number of instances of one entity that are
associated with one instance of a related entity eg:
1. One LECTURER can teach 1..4 CLASSEs Example 1
2. One HOD manages 0..1 DEPARTMENT Example 2
– Multiplicity refers to both the minimum and maximum number of
instances (MIN 1…1 MAX 1…4), (MIN 1…0 MAX 1…1)
• Participation - determines whether all occurrences of an entity
participate in the relationship or not.
• Participation is 1 in example 1, meaning it is mandatory to participate
– Participation can be 0 in example 2, meaning it is optional to participate
• Cardinality expresses the maximum number of entity occurrences
associated with one occurrence of related entity
– Cardinality is 4 in example 1 and 1 in example 2
31
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

32
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Multiplicity example

Multiplicity?
Participation?
Cardinality?
33
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Multiplicity example

Multiplicity MIN (1…1) and MAX (1…4)


Participation mandatory for both
Cardinality 1 and 4
34
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Existence Dependence – Example

• Entity is existence dependent if it can exist in the


database only when it is associated with another
related entity occurrence
• If you have an EMPLOYEE table and a
DEPENDENT table:
– What will the primary key be in each table?
– In the DEPENDENT table, where is the foreign key?

36
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Existence Dependence
• Existence dependence
– Entity exists in database only when it is associated with
another related entity occurrence
– E.g. it has a mandatory foreign key – it can’t be null

37
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Weak Entities
• A weak entity meets two conditions
– Existence-dependent
• Cannot exist without entity with which it has a relationship
– Strong relationship
• Has a primary key that is partially or totally derived from parent
entity in relationship
– Example: DEPENDENT is existence-dependent on EMPLOYEE
and in a strong relationship meaning {PK} in DEPENDENT
table may be EMP_NUMBER (ie it is also the {FK})

38
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Summary
• Weak entity
– If FK is part of the PK
– Existence Dependent
– Strong relationship

• Strong entity
– If FK is not part of the PK
– Existence Independent
– Weak relationship

39
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

40
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

B. Developing an ER Diagram

• Database design is iterative rather than linear or


sequential process
• Iterative process
– Based on repetition of processes and procedures

41
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Steps in Developing an ER Diagram


• Building an ERD usually involves the following activities:
1. Create detailed narrative of organization’s description of
operations
2. Identify business rules based on description of operations
3. Identify main entities and relationships from business rules
4. Develop initial ERD
5. Determine the multiplicities ie the participation and
cardinalities for each relationship
6. Identify attributes and primary keys that adequately
describe the entities
7. Revise and review ERD

42
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

43
Developing an ER Diagram - example 2
DATABASE SYSTEMS: Design Implementation and Management (Rob,
Coronel & Crockett 9781844807321)

• Tiny University
1. Tiny University is divided into several schools
2. Each school is administered by a dean, who is a lecturer
and has a grade of professor
3. Each school is composed of several departments
4. Each department may offer several courses
5. Each department may have many lecturers assigned to it
6. Each lecturer may teach up to four classes; each class is a
section of a course
7. Students may enroll in several classes, but students take
each class only once during any semester
8. Each department has many students
9. Each student has only a single major and is associated with
a single department 44
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

• Tiny University is divided into several schools


– Each school has a unique code and name

• Each school is administered by a dean, who is a


lecturer and has a grade of professor
– Each lecturer has a unique ID number
– Information collected include name, surname, e-mail
and professor grade

• Each school is composed of several departments


– Each department is assigned a number and name

45
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

• Each department may offer several courses, but


each course is only offered by one department
– For each course a specific number is assigned
– Other information required include course credits,
description and official title

47
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

• For each course there are several classes that


must be taken, but each class only belong to a
specific course
• For each class a specific code is assigned
• Other information collected include class time
and section

49
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

• Each department may have no or many lecturers


assigned to it
• Each lecturer are employed only in one
department
• Each department is chaired by a maximum of 1
lecturer

51
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

• Each lecturer may teach many classes, although


professors do not teach any classes
• Each class is taught by only 1 lecturer

53
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

• Students may enrol in several classes, but


students take each class only once during any
semester
• Information required from students are student
number, first name, last name and e-mail
• Enrolment date and grade must be recorded

55
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

• Each department has many students


• Each student has only a single major and is
associated with a single department

57
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Each lecturer advises many students


Each student is only assigned to 1 lecturer

59
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

• Each class is associated with a room of which the


room number and type is recorded
• Each room is housed in a building of which the
building code, name and location is recorded

61
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Developing an ER Diagram – Summary


of components

63
Developing an ER Diagram – Completed2
DATABASE SYSTEMS: Design Implementation and Management (Rob,
diagram
Coronel & Crockett 9781844807321)

64
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

C. Database Design Challenges:


Conflicting Goals
• Database design must conform to design
standards
• High processing speeds are often a top priority in
database design
• Quest for timely information might be focus of
database design

65
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Design standards
• Guide in developing logical structures that
minimize data redundancies
• Minimize chance of anomalies occurring
• Avoiding nulls
• Govern the presentation of all components within
the database design
• Needed to formulate a proper design process,
evaluate existing design and trace the widely local
impact of changes in design
66
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Processing speeds

• Needed for large numbers of transactions


• Minimal access times through minimizing the
number and complexity of logically desirable
relationships

67
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Information requirements

• Complex information requirements may dictate


data transformations, and they may expand the
number of entities and attributes within the
design

68
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Summary

• Entity relationship (ER) model


– Uses ERD to represent conceptual database as viewed
by end user
– ERM’s main components:
• Entities
• Relationships
• Attributes
– Includes multiplicity notation.

69
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)

Summary – 2

• Multiplicities are based on business rules


• In ERM, *..* relationship is valid at conceptual
level
• ERDs may be based on many different ERMs
• Database designers are often forced to make
design compromises

70

You might also like