0% found this document useful (0 votes)
59 views46 pages

The Entity-Relationship Data Model

This document discusses the Entity-Relationship (E/R) data model for conceptual database design. It describes the key elements of an E/R diagram including entity sets, attributes, binary and ternary relationships, and relationship types. Examples are provided to illustrate

Uploaded by

vieres
Copyright
© Attribution Non-Commercial (BY-NC)
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)
59 views46 pages

The Entity-Relationship Data Model

This document discusses the Entity-Relationship (E/R) data model for conceptual database design. It describes the key elements of an E/R diagram including entity sets, attributes, binary and ternary relationships, and relationship types. Examples are provided to illustrate

Uploaded by

vieres
Copyright
© Attribution Non-Commercial (BY-NC)
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
You are on page 1/ 46

Chapter 2

The Entity-Relationship Data


Model
Objectives
Able to draw an E/R diagram based on
given problems

Able to understand an E/R diagram

Practice the design principles


2.0 Introduction
Process of designing a database begins
with :
 What is the information ?
 The relationships among that information

The structure of the database, the


database schema - can be expressed
using several languages or notations
2.0 Introduction (cont.)
There are several numbers of notation can be
used to design a database:

 E/R Model – a traditional but a yet a popular approach

 Object Definition Language (ODL) – the standard for


object oriented database

 ‘semistructured data’ – unusual amount of flexibility in


the structures that the data may form. XML is an
important embodiment of the semistructured model
(using html tags to model a data)
2.0 Introduction (cont.)

E/R Relational Relational


Ideas
Design Schema DBMS

The database modeling and implementation process


2.1 Elements of E/R Model
In E/R model, the elements of the
database is represented graphically using
E/R diagrams using three principal
elements types:

 Entity sets
 Attributes
 relationships
2.1.1 Entity Sets
Is an abstract object of some sort, and a
collection of similar entities forms an entity
set.

Discuss – what element type is similar with


entity sets in object oriented programming
2.1.1 Entity Sets (cont)
Example 1 : Name the entities that might
involve in a ‘Movie Produced’ database

Example 2 : Name the entities that might


involve in a ‘King Kong Movie’ database
2.1.1.1 Weak Entity Sets
Occasionally, entities of an entity set need
“help” to identify them uniquely.

Entity set E is said to be weak if in order


to identify entities of E uniquely, we need
to follow one or more many-one
relationships from E and include the key
of the related entities from the connected
entity sets.
Weak Entity Types
An entity that does not have a key attribute

A weak entity must participate in an identifying


relationship type with an owner or identifying
entity type

Entities are identified by the combination of:


 A partial key of the weak entity type

 The particular entity they are related to in the

identifying entity type


Example

name is almost a key for football players, but there


might be two with the same name.

number is certainly not a key, since players on two


teams could have the same number.

But number, together with the team name related to


the player by Plays-on should be unique.
In E/R Diagrams

name number name

Players Plays- Teams


on

• Double diamond for supporting many-one relationship.


• Double rectangle for the weak entity set.
2.1.2 Attributes
The properties of an entity

Give example based on the entity you’ve


suggested in previous discussion
Attributes
An entity is represented by a set of attributes,
that is descriptive properties possessed by all
members of an entity set.
student = (student-id, student-name,
student-street, student-city)

Domain – the set of permitted values for each


attribute
Attribute types:
 Simple and composite attributes.
 Single-valued and multi-valued attributes
 Derived attributes
Can be computed from other attributes
Composite Attributes

MultiValued Attributes:
Attribute that has more than one value: set of telephone numbers
set of addresses in :
1 Person
2 Name
2 telephone#
2 address
Derived Attributes
Attribute whose value is derived from other attributes
1 Person
2 Name
2 telephone#
2 address
2 DOB
2 Age derived from DOB
and current date
2.1.3 Relationships
Relationship are connections among two
or more entity sets .

What is the relationships in the following


example:
 Actors – movie
 Lecturer – students
 Director – movie
 Cars - mechanic
2.1.4 E-R Diagrams

 Rectangles represent entity sets.


 Diamonds represent relationship sets.
 Lines link attributes to entity sets and entity sets to relationship sets.
 Ellipses represent attributes
 Double ellipses represent multivalued attributes.
 Dashed ellipses denote derived attributes.
 Underline indicates primary key attributes (will study later)
ER Diagrams - Symbols
2.1.4 Entity-Relationship Diagrams (cont.)

Try to draw your first E/R diagrams based


on three main entities of database Movie –
stars, studios, movies

Student, subject, lecturer, faculty in


Student Registration System

Supplier, item, customer in Warehouse


system
name address
title length

movies Stars in stars

year
type

Owns name

studios

address
2.1.5 Instances of an E/R Diagram
E/R diagrams are notation for describing the
schema of databases, that is their structure

A database describe by an E/R diagram will


contain particular data , called database
instance

Imagining this data can help us to think about


our design, before we convert to relations and
the data takes on physical existence
2.1.5 Instances of an E/R Diagram (cont)

Eg An instances of the lecturer-taught


relationship

Lecturer Subject

tuple Nizam Database

Malik Network Security

Firkhan Internet Programming


2.1.6 Multiplicity of Binary E/R relationship

Binary relationship involves two entities related


together

Eg lecturer taught subject

In general, any member in lecturer can connect


to any number of members in subject

But there is restriction on this “relationship


multiplicity”
2.1.6 Multiplicity of Binary E/R relationship (cont)

Then :

1. If each member of lecturer can be connected


(through taught) to at most one member of
subject, then we say taught is many-one from
lecturer to subject. Note that in many-one
relationship from lecturer to subject, each entity
in subject can be connected to many members
of lecturer, vice versa.
2.1.6 Multiplicity of Binary E/R relationship (cont)

2. If taught is both many–one from lecturer to


subject and subject to lecturer, then we say
taught is many-many.

3. If taught is neither many-one from lecturer to


subject or subject to lecturer, then we say
taught is one-one. In a one-one relationship an
entity of either entity set can be connected to
at most one entity of other set.
Notation
M
N
lecturer taught subject

Many to many

M 1

lecturer taught subject

Many to one

1 1
lecturer taught subject

One to one
One-To-One Relationships

Put arrows in both directions.


1 Best- 1
Manfs Teh
seller

Design Issue:
Here, manufacturer is an Entity Set.
In earlier diagrams it is an attribute.
Which is right?
One-To-Many Relationship

In the one-to-many relationship a loan is


associated with at most one customer via
borrower, a customer is associated with
several (including 0) loans via borrower
Many-To-One Relationships

In a many-to-one relationship a loan is


associated with several (including 0)
customers via borrower, a customer is
associated with at most one loan via borrower
Participation of an Entity Set in a Relationship
Set
 Total participation (indicated by double line): every entity in the entity
set participates in at least one relationship in the relationship set
 E.g. participation of loan in borrower is total
 every loan must have a customer associated to it via borrower
 Partial participation: some entities may not participate in any
relationship in the relationship set
 E.g. participation of customer in borrower is partial
Many-To-Many Relationship

A customer is associated with several (possibly 0)


loans via borrower
A loan is associated with several (possibly 0)
customers via borrower
Types of Binary Relationships

Many-many Many-one One-one

Representation of Many-One

Many-one E/R: arrow pointing to “one.”


Exercise
Recognize type of relation that correspond to the sample data
Lecturer Subject Lecturer Subject

Ahmad Database Ahmad SQL


Ahmad Java
Ali Java
Ali C++
Abu C++ Abu Internet

Lecturer Subject Lecturer Subject


Siti SQL Ahmad SQL
Ahmad SQL Ahmad Java
Ali C++ Ali Java
Abu Internet Abu Internet
2.1.7 Ternary Relationship
E/R model allow us to define a relationship that
involve more than two entity sets.

In practice, ternary or higher degree relationship


are rare, but they are occasionally necessary to
reflect the true state of affairs.

A multiway relationship in an E/R diagram is


represented by lines from the relationship
diamond to each of the involved entity sets.
2.1.7 Ternary Relationship (cont)

M N
stars contracts movie

studio

How do you ‘read’ the above diagram?


2.1.7 Ternary Relationship (cont)
Stars – Jon Joned in movie Kong Kang
acted for Universal Studio

Universal Studio contracted many stars to


acted in their new film The Mami

Samad Bon contracted with Universal


Studio to acted in The Mami 2, The Mami
3 and The Mami 4.
2.1.8 Unary Relationships
It is possible that one entity set appears two or
more times in a single relationship.

If so, we draw as many lines from the


relationship to the entity set as the entity set
appears in the relationship

Each line to the entity set represents a different


role that the entity set plays in the relationship
2.1.8 Unary Relationships (cont)
1

movie Sequel-of

Unary
1 relationship

subject prerequisit
e

M
2.1.8 Roles in Relationships (cont)

Stars Movies
M M

Contracts

Producing
Studio of star
studio

1
1
Studios

(studio1, studio2, stars, movie)


2.1.9 Cardinality in Relationships
Cardinality expresses the specific number
of entity occurrences associated with one
occurrence of the related entity.
In the Chen model, cardinality is indicated
by placing the appropriate numbers beside
the entities, using the format (x,y).
2.1.9 Cardinality in Relationships
The first cardinality value represents the
minimum value, while the second
cardinality is represents the maximum
value. In the Crow’s Foot model, the
cardinality is indicated through the use of
symbols.
2.1.9 Cardinality in Relationships

Connectivity

1 M
PROFESSOR Teaches CLASS
(1,4) (1,1)

Cardinalities

CHEN MODEL
2.1.9 Cardinality in Relationships

Connectivity

PROFESSOR CLASS
Teaches

Cardinalities

CROW’S FOOT MODEL


Exercise
Case Study: A company has several departments. Each department has a supervisor and at least one employee.
Employees must be assigned to at least one department. Project will be given to the employee and it will be done in a
group. At least one employee is assigned to one project or more. The important data fields are the names of the
departments, projects, supervisors and employees, as well as the supervisor and employee number, department code
and a unique project number. 
Exercise
Create an ER Diagram for the following requirements with the appropriate attributes for each entity type and structural constraints for each relationship type.

(a)An INVOICE is written by a SALESREP. Each sales representative can write many invoices, but each invoice is written by a single sales representative.
(b)The INVOICE is written for a single CUSTOMER. However, each customer can have many invoices.
(c) An INVOICE can include many details (DETAIL), which describe the products bought by the customer.
(d) The product information is stored in a PRODUCT entity.

You might also like