You are on page 1of 26

MIRPUR UNIVERSITY OF SCIENCE AND TECHNOLOGY

DEPARMENT OF SOFTWARE ENGINEERING


DATABASE SYSTEMS
(Lecture # 3)
Database Schema and ER Model Constructs

Engr. Saba Zafar


(Lecturer)

Date: 21-11-2023
LECTURE CONTENTS

• E-R Model Constructs

• Strong Entity Type vs Weak Entity Type

Database Systems 3
E-R Model Constructs
• Entities – It is a person, place, object, event, or concept in user environment
about which organization wishes to maintain data
• Person: EMPLOYEE, STUDENT
• Place: STORE, WAREHOUSE, STATE
• Object: MACHINE, BUILDING, AUTOMOBILE
• Event: SALE, REGISTRATION, RENEWAL
• Concept: ACCOUNT, COURSE, WORK CENTER

• Entity Type – Collection of entities (often corresponds to a table) that


share common properties or characteristics (can be called Entity)
• It is always singular as its name represent collection of items
• We use capital letter for names of entity type i.e. STUDENT, EMPLOYEE, SALE
• It is described just once in the database using metadata
• Entity instance –Single occurrence of Entity Type (often corresponds to
a row in a table).
• Many entity instances of any entity type may be represented by data stored in
database
• For Example: There is one EMPLOYEE entity type in most organization, but there
may be hundreds of entity instances of this entity type stored in the database
Database Systems 4
Difference b/w Entity Type and Entity Instance

Database Systems 5
What Should an Entity Be?

• SHOULD BE:
• An object that will have many instances in the database
• An object that will be composed of multiple attributes
• An object that we are trying to model

• SHOULD NOT BE:


• A user of the database system
• An output of the database system (e.g., a report)

Database Systems 6
Example of Inappropriate entities

System System
user Inappropriate output
entities

Appropriate
entities

Database Systems 7
Strong Entity Type vs Weak Entity Type
Strong Entity Type:
• It can exists independently of other entity types
• Entity instances of each Strong Entity Type have a unique
characteristics (identifier or key)
• For Example: EMPLOYEE, STUDENT, ORDER, SALE
Weak Entity Type:
• Its existence depends on some other entity type
• It does not have its own identifier
• Represented by double-lined rectangle
• The entity type on which weak entity depends is called
Identify owner
• Identifying Relationship: Relationship between weak entity
and its owner i.e. carries as shown in figure
Database Systems 8
Weak Entity and Identify Owner

Database Systems 9
E-R Model Construct (cont…)
• Relationship – It is an association representing an interaction among
instances of one or more entity types, so it has a verb phrase name
• For Example: EMPLOYEE completes a COURSE. Here complete is a
relationship

• Relationship Type– Category of relationship. Meaningful association


between (link ) entity types

• Relationship Instance – Link between entity instances


• Each relationship instance includes exactly one entity instance from
each participating entity type

• Attribute–Property or characteristic of an entity or relationship type


(often corresponds to a field in a table)

Database Systems 10
Relationship Type vs Relationship Instance

Database Systems 11
Basic E-R notation

Entity
Attribute
symbols
symbols

A special entity
that is also a Relationship
relationship symbols

Relationship
degrees
specify number
of entity types Relationship
involved cardinalities
specify how
many of each
entity type is
allowed
Database Systems 12
Attributes
• Attribute–Property or characteristic of an entity or
relationship type. It has a noun name.
• For Example: The attributes of STUDENT entity type can be
Student_ID, Student_Name, Home_Address, Tel_No

• Classifications of attributes:
• Required versus Optional Attributes
• Simple versus Composite Attribute
• Single-Valued versus Multi-valued Attribute
• Stored versus Derived Attributes
• Identifier Attributes

Database Systems 13
A composite attribute

An attribute broken
into component
parts

Entity with multivalued attribute (Skill) and derived attribute


(Years_Employed)

Derived
Multivalued
from date
an employee can have
employed and
more than one skill
current date

Database Systems 14
Identifiers (Keys)

• Identifier (Key)–An attribute (or combination of attributes) that


uniquely identifies individual instances of an entity type
• Simple versus Composite Identifier
• Candidate Identifier – An attribute that could be a key…satisfies the
requirements for being an identifier

Database Systems 15
Characteristics of Identifiers

• Will not change in value e.g. your Roll No


• Will not be null
• No intelligent identifiers (e.g., containing locations or
people that might change)
• Substitute new, simple keys for long, composite keys

Database Systems 16
Simple Identifier Attribute: An atomic attribute that can’t be
broken down into smaller meaningful components i.e. Student_ID
Composite Identifier Attributes: An attribute that has
meaningful component parts i.e. Flight_ID
Figure 3-9 Simple and composite identifier attributes
The identifier is boldfaced and underlined

17
More on Relationships
Relationship Types vs. Relationship Instances
• The relationship type is modeled as lines between entity
types…the relationship instance is between specific entity
instances

• Relationships can have attributes


• These describe features related to the association between
the entities in the relationship

Database Systems 18
Degree of Relationships
• Degree of a relationship is the number of entity types
that participate in it

• Unary Relationship
• Binary Relationship
• Ternary Relationship

Database Systems 19
Degree of Relationships

One entity Entities of


related to two different Entities of three
another of types related different types
the same to each other related to each
entity type other
20
Examples of relationships of different degrees

a) Unary relationships

Database Systems 21
Examples of relationships of different degrees

b) Binary relationships

Database Systems 22
Examples of relationships of different degrees

c) Ternary relationship

Note: a relationship can have attributes of its own

Database Systems 23
Sample E-R Diagram

Database Systems 24
REFERENCES
Database System Concepts latest Edition by Abraham
Fundamentals of database by Elmasri, latest edition
Date, C, J.: "An Introduction to Database Systems", latest Edition, Pearson, Boston.

Database Systems 25
THANKS

You might also like