0% found this document useful (0 votes)
22 views91 pages

Ch-04 (DB) - Entity - Relationship Model

Uploaded by

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

Ch-04 (DB) - Entity - Relationship Model

Uploaded by

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

DATABASE MANAGEMENT

Chapter 4
Entity- Relationship
Model
Contents
• Entity- Relationship Model
• Elements of E-R Model
• Existence Dependency
• Modeling Multi-valued Attributes
• Modeling Repeating Groups
• Modeling Time-dependent Data
• Supertypes & Subtypes
• Aggregation
• Specialization & Generalization
• Union Type or Category
• Projects - E-R Model
Entity- Relationship Model
Chapter 4 - Entity- Relationship Model
Entity- Relationship Model
• Entity-Relationship model (or E-R model)  popular and widely used conceptual
data model
• Logical representation of the data for an organization or a business area
• Data/information shown through ER-model is ultimately implemented as a
database
• E-R model describes the data structure of the database that is implemented as a database
• 1976  E-R model was introduced by Peter Chen
• Expressed in terms of
• entities (i.e. objects) in a system
• relationships between entities
• attributes (or properties) of both the entities and their relationships
• Allows logical designer to specify constraints on the entities or relationships
between entities
• E-R model is expressed graphically with the help diagram
Advantages E-R Model
+ Simplicity
• Because if we know the relationships between entities and attributes, then we can easily
draw an ER diagram
+ Visual Representation
• Describes the data structure of the database graphically with the help of the E-R diagram
• Helps a database designer to create a successful database very easily and efficiently
+ Effective Communication Tool
• For a database designer to get different views of data of an organization
+ Integrated with Relational Data Model
• Integrated with a relational data model
• Can easily be converted to the relational data model by simply converting the E-R model
into tables
+ Easy Conversion to any Data Model
• Can easily be converted to another data model like a hierarchical data model, or network
data model
E-R Diagram
• Graphical representation of an
E-R model
• Shows different entities and their
relationships to each other
within a system
• Different standard symbols are
used to represent entities and
relationships between them
• Basically, E-R diagrams are the
designing tools and
documentation for a system
Elements of E-R Model
Chapter 4 - Entity- Relationship Model
Entities
• Entity  Anything in a real-world system that is important in the system and
has a set of different attributes or properties
• An entity can be
• an object with a physical existence  a people, a place, etc.
• a concept or idea  a university course, account, a job, an event that is relevant to a
given system
• For example: a college system may include entities like students, teachers,
courses, and subjects, etc.
• Person  Teacher , Student, Player, Doctor, Employee, Customer
• Place  City, Country, Province or State, Store, Warehouse
• Object  Furniture, Vehicle, Equipment, Building
• Concept  Account, Programming, Invoice, Marks, Course
Entity Type
• A collection (or set) of entities that have the same attributes (properties or characteristics)
• Entity type or Entity class
• For example:
• Entity  a particular employee of an organization
• Entity Type  a set of all employees of an organization
• Similarly, STUDENT and TEACHER represent two different entity types in a college or
university
• STUDENT entity type  a set of all students
• TEACHER entity type  a set of all teachers
• In E-R model  capital letters are used for name of entity type
• A rectangle symbol is used to represent an entity type
• Name of the entity type is written inside this symbol
• All entities in a specific entity type share the same attributes
• but each entity has its own value(s) for each attribute
Entity Set
• A set of all entities in a particular entity type in the database at a given point
of time
• For example
• Entity set EMPLOYEE  consist of all employees in an organization
• Entity set STUDENT  consist of all students in the university/college
• Same name is usually used for both entity type and entity set
• STUDENT refers to both entity type as well as a set of all students in the database
Entity Instance
• A member of an entity type
• Representation of a particular entity
• such as a student of roll number 104
• Described by the values of attributes of the entity
• Entity type  described just once in a database
• one STUDENT entity type in most universities or colleges
• Many instances of that entity type  represented by data stored in database
• May be hundreds or thousands of instances of STUDENT entity type stored in database
• Each entity instance of an entity type has its own values
Attributes
• Characteristics or properties of an entity that describe it
• All attributes have values
• For example  a particular student of a class can be described by his/her roll
number, name, father name, obtained marks, address, mobile number, etc.
• Attributes of a student entity
• Attributes are named
• If an attribute consists of a single word  then use first letter as a capital letter and
other letters as lowercase letters
• If an attribute consists of two or more words  then start each word with a capital letter
and other letters of the word as lowercase letters
• All instances of a particular entity type have the same attributes
• STUDENT entity type may have attributes Roll_No, Name, Father_Name, Marks,
Address, and Phone_No, etc.
• In E-R diagrams  represented by ellipse (or oval shape)
Attribute Domain
• Values are assigned to the attributes of an entity
• Attribute values that describe each instance of an entity type become a major part of the data
stored in a database
• There exists a domain or range of values that can be assigned to attributes
• For example  a student's name cannot be a numeric value. It has to be alphabetic
• A student's age cannot be negative, etc.
• Attribute domain  A possible set of values that can be assigned to an attribute of entity
• A value set of an attribute
• Attribute domain may consist of a range of values or some specific values
• "Marks“, maximum value = 100  assign values from 0 to 100
• Domain for attribute "Gender“  either be "Male" or "Female“
• Different attributes can have the same domain
• Domain of an attribute "Name" is difficult to define
• because it consists of all alphabetic names of students
• An association of a domain with its attribute ensures the integrity (or accuracy) of a database
• ensures correct data entry
• Can specify the domain for an attribute at the DBMS level or application level
Required Attribute & Optional
Attribute
• Each attribute of an entity (or instance of an entity type) has a possible value
associated with it
• Required attribute  attribute that must have a value for every entity instance
of an entity type
• Optional attribute  attribute that may not have a value for every entity
instance of an entity type
• Required Attributes  Roll-No, Name, and Address
• Optional Attributes  Cell_No
• because some students may not have a mobile number or cell number
Types of Attributes
Simple Attribute
• An attribute that cannot be divided into smaller components
• Atomic attribute
• STUDENT entity type  "Marks" and "Roll_No"
Composite Attribute
• An attribute that can be divided into smaller components
• Each component also represents a simple attribute with independent
meanings
• STUDENT entity type
• “Name”  First-Name, Middle-Name, Last-Name
• Address attribute  ZipCode, City, StreetAddress
Types of Attributes
Single-Valued Attribute
• An attribute that can have only one (or single) value for each entity instance
• Example1  Age of a student
• a particular student cannot have two values for the "Age" attribute
• Example2  "Roll_Number"

Multi-Valued Attribute
• An attribute that can have two or more values for each entity instance
• Examples  a student can have more than one phone number or address
• Double-line ellipse is used to represent a multi-valued attribute
Types of Attributes
Stored Attribute
• An attribute that is stored in a database
• Base attribute
• Most of the attributes are stored attributes because their values are stored and accessed from the
database

Derived Attribute
• An attribute that does not exist in the physical database but its value is calculated (or derived) from
the values of other related attributes stored in a database
• For example  "Age" and "Date-of-Birth" of a student
• If date-of-birth is stored in database  age can be found out
• No need to store age of the student in the database if date-of-birth is stored
• Stored Attribute  "Date-of-Birth“
• Derived Attribute  "Age“
• Similarly
• Stored Attribute  attributes in which marks of different subjects are stored
• Derived Attribute  Total and average marks
Identifier
• Identifier  An attribute (or a set of attributes) whose value uniquely identifies
an entity instance among other instances of the entity type
• Two or more instances of the entity type cannot have the same value for the
identifier attribute
• For example  STUDENT entity type
• Each student is identified by his/her "Roll-No" or "Student ID“
• Identifier  "Roll-No" or "Student ID"
• "Student Name" cannot be used as an identifier because many students may have the
same name
• In relational model  primary key is used to identify the records uniquely
• In E-R diagram  an entity identifier is underlined
Identifier
Simple Identifier
• An identifier that consists of only one attribute
• For example  single attribute "Roll-No" of the STUDENT entity type as an identifier
Composite Identifier
• For some entity types, there is no single attribute that can serve as the identifier
• Two or more attributes used in combination may serve as the identifier
• Composite identifier  An identifier that consists of two or more attributes
• For example  a student can be identified by using both its "Roll-No" and "ClassID“
• An identifier that consists of a composite attribute  composite identifier
• A composite attribute can be divided into smaller components i.e. two or more
attributes
Relationships
• Relationship  an association among instances (or entities) of one or more entity types
• Indicates how the instances or entities of entity type(s) are related to each other
• Entity types that participate in a relationship  Participants
• A relationship is established on the basis of interaction among these entities
• For example  relationship exists between teacher and students because teacher teaches
students
• Each relationship is given a name
• An action word (such as teach, manage, and order) is used to name a relationship
• For example  relationship between entity types MANAGER and DEPARTMENT: Manages
• In E-R diagram  a relationship is indicated by a diamond symbol
• The diamond symbol is placed between the entity types' symbols connecting with lines
• The entities can be associated /connected to one another in different ways
• A BOOK-STORE orders BOOK
• A BOOK-STORE displays BOOK
• A BOOK-STORE stocks BOOK
• A BOOK-STORE sells BOOK
Degree of Relationships
• A relationship may consist of many entity types
• Degree of Relationship  number of entity types that participate in a
relationship
• Degree of relationship "writes“ = 2
• because only two entity types are participating in this relationship, i.e. AUTHOR and
BOOK

• Binary relationship
• Unary relationship
• Ternary relationship
Binary Relationship
• Relationship between instances of two entity types
• Two entity types participate in this type of relationship
• Binary relationship has degree two
• Most common type of relationship used in data modeling (i.e. E-R diagrams)
• Types of binary relationship
• One-to-one relationship
• One-to-many relationship
• Many-to-many relationship
Binary Relationship
One-to-One (1:1) Relationship
• Used when a single instance of the first entity type is related to a single
instance of the second entity type
• For each instance of the first entity type, there is only one matching instance
in the second entity type
• On the other hand, for each instance in the second entity type, there is only
one matching instance in the first entity type

 One Chairman runs only one Department


 One Manager manages one Branch of a bank
 One Person has one Passport
 One Patient is assigned one Bed in hospital
 One Country has only one National Flag
Binary Relationship
One-to-Many (1:N) Relationship
• Used when a single instance of the first entity type can be related to many instances of
the second entity type
• For each instance in the first entity type, there can be many matching instances in the
second entity type
• On the other hand, for each instance in the second entity type, there is only one
matching instance in the first entity type
• For example  a mother may have many children, but a child can have only one mother
• In E-R diagram, Crow’s paw symbol is used to indicate many instances

 One Ward in a hospital can have many Patients


 One Airplane travels with many Passengers
 One House shelters many Persons
 One College can have many Departments
 One College can have many Students
 One Country can have many Provinces
Binary Relationship
Many-to-Many (M:N) Relationship
• Used when each instance in the first entity type, there can be many matching
instances in the second entity type
• On the other hand, for each instance in the second entity type, there can also
be many matching instances in the first entity type
Unary Relationship
• Relationship between the instances of a single entity type
• Only one entity type participates in this type of relationship
• Unary relationship has degree one
• Also known as a recursive relationship
• Types of unary relationship
• One-to-one relationship
• One-to-many relationship
• Many-to-many relationship
Unary Relationship
One-to-One (1:1) Relationship
• Represented in a similar way as the one-to-one binary relationship
• If one person can marry only with one person (as in most of the cases)
• recursive relationship between two PERSON(S) entity type
• A person is married to a person
• On the other hand, a person is married by another one person
Unary Relationship
One-to-One Relationship
• Represented in a similar way as the one-to-one binary relationship
• If one person can marry only with one person (as in most of the cases)
• recursive relationship between two PERSON(S) entity type
• A person is married to a person
• On the other hand, a person is married by another one person
Unary Relationship
One-to-Many Relationship
• Relationship named as "Manages" that associates employees of an
organization with another employee who is their manager
• Read as: an employee manages many employees (i.e. an employee is a
manager of many employees)
• On the other hand, many Employees are managed by one Employee
Unary Relationship
Many-to-Many Relationship
• Represents the situation in which doctors give treatments to other doctors
(doctors as patients)
• Relationship shows that a doctor is treated by many other doctors
• On the other hand, a doctor treats many other doctors
Ternary Relationship
• A ternary relationship is a simultaneous relationship between the instances of
three entity types
• Three entity types participate in this type of relationship
• Ternary relationship has degree three

"A Supplier can supply many Parts in a "Many teachers may teach many classes
particular Project" with many students"
Cardinality Constraints
• Cardinality constraint  A rule that specifies the number of instances of one entity type
that can (or must) be associated with each instance of another entity type
• The relationship types usually have certain constraints that limit the number of
instances of one entity type that can be associated with each instance of another
related entity type
• Relationship type  A meaningful association among entity types
• Entity types: A and B  cardinality
• one-to-one relationship between A and B
• Each instance in A can be associated with exactly one instance in B
• On the other hand, each instance in B must be associated with exactly one instance in A
• one-to-many relationship between A and B
• Each instance in A can be associated with many instances in B
• On the other hand, each instance in B must be associated with exactly one instance in A
• many-to-many relationship between A and B
• Each instance in A can be associated with many instances in B
• On the other hand, each instance in B can also be associated with many instances in A
Cardinality
• Cardinality  Number of instances of one entity type that can be associated
with each instance of another entity type
• There are two categories of cardinality
• Maximum cardinality
• Minimum cardinality
Maximum Cardinality
• Maximum number of instances of one entity type that may be associated with
each instance of another related entity type
• Either "one" or "many“
• "one" denoted by small vertical line () on relationship line, next to the first entity type
or before the second entity type
• "many" denoted by crow’s foot ( > ) symbol

• A department may have many


teachers. On the other hand, a
teacher belongs to one department only.
Minimum Cardinality (Modality)
• Minimum number of instances of one entity type that may be associated with
each instance of another related entity type
• Either "zero" or "one“
• Minimum cardinality refers to the modality of relationship
• Modality defines the nature of the relationship that whether it is optional or
mandatory (i.e. compulsory)
• Minimum cardinality zero  optional
• Denoted by a small circle "O" on relationship line
• For statements like
• "An employee may have a car“
• "A student may have read many books"
• Minimum cardinality one  mandatory
• Denoted by a small vertical line "" on relationship line
• For statements like
• "An employee must have a car“
Notations for Relationship
Cardinalities
Examples for Relationship
Cardinalities
Existence Dependency
Chapter 4 - Entity- Relationship Model
Existence Dependency
• An existence dependency or existence constraint can occur between two
entity types
• Existence dependency  an instance of one entity type cannot exist without
the existence of an instance of another related entity type
• If the existence of entity A depends on the existence of entity B, then A is said
to be existence dependent on B
• If B is deleted, A must also be deleted
• A is subordinate and B is dominant
Strong Entity Type
• The entity type whose existence does not depend on some other entity types
• A strong entity type can exist independently of other entity types
• Independent entity type, parent entity type, owner entity type, dominant
entity type
• The instances of strong entity types always have an identifier that consists of a
single attribute or a combination of attributes
• Identifier uniquely identifies each instance of the strong entity type
• In E-R diagram  indicated by a single line rectangle
Weak Entity Type
• An entity type whose existence depends on some other entity type
• Dependent entity type, child entity type, subordinate entity type
• An instance of a weak entity type cannot exist independently but depends on the
existence of an instance of another entity type (strong entity type)
• For example  in a college/university, a faculty member cannot exist without a
corresponding department
• Entity type on which the weak entity type depends  identifying owner or simply
owner
• A relationship between a weak entity type and its owner  identifying relationship
• Weak entity type does not have its own identifier
• In E-R diagram
• Weak entity type  indicated by a double line rectangle
• Identifying relationship  indicated by double line diamond shape
• Weak entity type has an attribute that serves as a partial identifier  double underline
• In the database design, a full identifier will be formed for the weak entity type by
Associative Entity
• An entity type that associates the instances of one or more entity types with
one another
• It also contains attributes that are unique to the relationship between those
entity instances
• Also known as gerund; because the relationship name (a verb) is usually
converted to an entity name that is a noun
• Database relational model does not offer direct support to many-to-many
relationships
• Solution  to create another table to hold necessary information for this relationship
• New table is called an associative entity
• Attributes may also be associated with the relationship
Modeling Multi-valued
Attributes
Chapter 4 - Entity- Relationship Model
Modeling Multi-valued Attributes
• Some attributes have multiple values for a single instance of an entity type
• For example  attribute "Skill" of the EMPLOYEE entity type
• An employee may have more than one skill
• In conceptual design process  multi-valued attributes are often removed
from the entity types for which they appear
• Each multi-valued attribute (or each repeating group) is converted into a
separate entity type and then it is connected to the entity type from which it
was removed
• Typically, to become a successful entity type, SKILL must have more than one
attribute
Modeling Repeating
Groups
Chapter 4 - Entity- Relationship Model
Modeling Repeating Groups
• Repeating group  A set of two or more multi-valued attributes that are
logically related
Modeling Time-dependent
Data
Chapter 4 - Entity- Relationship Model
Modeling Time-dependent Data
• Sometimes, the values of attributes of an entity change with time
• For example, in database containing information about medicines of a medical store
• unit price of each medicine may change over a period of time
• For accounting, billing, and other purposes, we need a detail of the prices and the
time period over which each unit price was effective

• Value of "Price" attribute depends upon date and time  "Time stamp“
• May be associated with system date and time
• System date and time may be recorded into the database with each transaction
Supertypes & Subtypes
Chapter 4 - Entity- Relationship Model
Supertypes & Subtypes
• Entity type  a collection of entities that have the same attributes (properties or
characteristics)
• In some situations, an entity type can be divided into several subgroups or subtypes
• Supertype  entity type that can be divided into subtypes
• A supertype is a generic entity type that has a relationship with one or more subtypes
• Subtype  a subset of a supertype and shares common attributes
• Behave like other entity types
• The identifiers (primary keys) of supertype and subtypes are always identical
• All properties of EMPLOYEE entity type apply
automatically to the TEACHER subtype but the
reverse is not true
• Each subtype has only one supertype
• Root  entity type at the top of a hierarchy
IS-A Relationship
• Relationship between each subtype and its supertype  IS-A or IS-AN relationship
• For example: "Shahbaz IS-A Student“, "Teacher IS-AN Employee“
• In ER diagram  A rectangle with rounded edges
• The relationship is read from subtype to supertype
• The identifier (or primary key) of supertype is included with each subtype
• For example: two types of teachers in a university  permanent teachers, visiting teachers
• Permanent teachers: Teacher-ID, Name, Address, Mobile-No, Basic Salary, and Allowances
• Visiting teachers: Teacher-ID, Name, Address, Mobile-No, Hours, and Rate Per Hour
• Each type has one or more attributes that are different from the other type
• Each subtype contains only those attributes that are not common
• Cardinality from subtype to supertype  mandatory
• because an instance of a subtype is always an instance of the supertype
• Cardinality from supertype to subtype  optional zero or one
• Exclusive relationship  subtype and supertype are mutually exclusive, and each instance
of the supertype is required to be a member of exactly one subtype
• Each teacher must be a permanent teacher or visiting teacher
Inheritance Associated with Supertype/Subtype
• Inheritance is another important concept associated with subtypes and
supertypes
• Property by which all attributes (and relationships) of a supertype become
attributes of its subtypes
• This important property makes it unnecessary to include the attributes and
relationships of supertype with the subtypes
• These attributes need not be attached to the subtypes
Aggregation
Chapter 4 - Entity- Relationship Model
Aggregation
• Aggregation  an abstraction concept, which is used to build a higher-level
object from its components
• For example, a computer is built by using various related components
• The aggregation abstraction allows designer to
• either decompose objects by breaking them into more detailed components
• or to aggregate objects, grouping them together into higher-level objects
• The hardware and software are further decomposed into their subparts
Specialization &
Generalization
Chapter 4 - Entity- Relationship Model
Specialization
• The process of identifying one or more subtypes and forming
supertype/subtypes relationships
• Specialization is the process of defining a set of subtypes or subclasses of the
supertype
• The subtypes are defined based on their characteristics
• Top-down process in which a higher-level entity type (supertype) is divided
into two more lower-level entity types (subtypes)
• Inheritance  subclasses inherit all the attributes and relationships of their
superclass
Generalization
• The process of identifying a general entity type from a set of specialized entity
types
• Generalization is the reverse process of specialization
• Bottom-up process in which two or more entities can be generalized to a
higher level entity if they have some attributes in common
• Common features of subclasses are identified and generalized into a single
super-class
Inclusion of Constraints on
Generalization and Specialization
• Subclasses are disjoint  if an entity can be a member of only one subclass
• Subclasses are non-disjoint  if an entity can be a member of more than one
subclasses (i.e. subclasses are overlapping)

A member of a library can be


A PERSON in a university can be EMPLOYEE, ALUMNUS,
Regular Member, Life Member,
and STUDENT at the same time
or Season Member.
Union Type or Category
Chapter 4 - Entity- Relationship Model
Union Type or Category
• Union Type or Category  A collection of entities of distinct entity types
• Triangle symbol is used to show the union type or category
• For example, the OWNER of a COMPANY can be a PERSON with a BANK
ACCOUNT
Projects - E-R Model
Chapter 4 - Entity- Relationship Model
Project 1
Step 1
• In a university/college, a student
called a class representative (CR)
represents other students of his
class. The STUDENT entity type may
have attributes like Roll-No, and
Name, Phone.
Step 2
• A student in a university/college
takes one or more courses according
to his/her choice. But in order to be
a student, he/she must take at least
one course. The COURSE entity type
may have attributes like CourseID,
CourseName, CourseFee, etc.
Project 1
Step 3
• A course is always taught by some teachers. A teacher cannot exist without a
corresponding course. A course may be taught by at least one or more
teachers. On the other hand, a teacher may teach at least one or more
courses.

Step 4
• Each department has a chairman, while a chairman chairs only one
department.
Project 1
Step 5
• In a university, a teacher belongs to one and only one department. However,
a department may have at least one or many teachers. The teacher can be
visiting, part-time, or full-time.
Project 1
COMPLETE E-R MODEL OF UNIVERSITY SYSTEM
Project 2
• Consider a University’s teaching environment where the following are the
main requirements:
• A student takes different courses.
• On one seat, only one student is enrolled.
• A course is listed only if there is some student(s) enrolled in it.
• There is only one instructor to teach a particular course; however, an Instructor can
teach different courses.
• To teach a particular course, multiple classes of the course may be arranged.
• In a particular class, only one course is taught.
• Construct an ER diagram for this environment of the university.
Project 3
• Draw an E-R model according to the following requirements and take your own
assumptions (if needed):
• In an educational institute, there are several departments and a particular student belongs to one
of them. Each department has a unique department number, a name, a location, a phone number,
and is headed by a professor.
• Professors have a unique employee ID, name, phone number. We like to keep track of the
following details regarding student name, unique roll number, sex, phone number, DOB, age, and
one or more email addresses.
• Students have local addresses consisting of the hostel name and the room number. They also have
home addresses consisting of house number, street, city, and PIN (Postal Index Number). It is
assumed that all students reside in the hostels.
• A course taught in a semester of the year is called a section. There can be several sections of the
same course in a semester; these are identified by the section number. Each section is taught by a
different professor and has its own timings and room to meet.
• Students enroll for several sections in a semester. Each course has a name, number of credits, and
the department that offers it. A course may have other courses as pre-requisites. Professors also
undertake research projects. These are sponsored by funding agencies and have a specific start
date, end date, and amount of money given. More than one professor can be enrolled in a project
also a professor may be simultaneously working on several projects. A project has a unique project
Project 4
• Design an ER diagram to model the following scenario:
• For each person, we need to record his CNIC number, name, and address.
• Authors write books.
• Editors ensure that books are written in a manner that is suitable for publication.
• Every editor works for just one publisher.
• Editors and authors have quite different skills; someone who is an editor cannot be an author
and vice versa.
• A book may have several authors, just one author, or no authors (published anonymously).
• Every book has one editor assigned to it, who has a liaison (link or connection) with the
author(s) in getting the book ready for publication.
• Each book has a title, and an edition number (e.g. 1st, 2nd, 3rd).
• Each published book is assigned a unique 13-digit number (its ISBN); different editions of the
same book will have different ISBNs.
• Publishers are companies that publish (market/distribute) books.
• Each publisher is required to have a unique registration number (Reg#).
• A publisher also has a name and address that need to be recorded.
• A particular edition of a book is published by exactly one publisher. (Solution is given in
Project 5
• Draw an E-R diagram for the following given 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, but possibly more
departments. At least one employee is assigned to a project, but an employee may be
on vacation and not assigned to any projects. The important data fields are the names
of the departments, projects, supervisors, and employees, as well as the supervisor
and employee number and a unique project number.
Project 6
• Draw an E-R Model for "Aqsa & Co" that is a Chartered Accountants Firm.
Use the following assumptions about the Human resources department.
• There are many departments of the company having attributes Department Number,
Phone Number, and Address.
• Each person in the organization is considered to be an employee including the owner.
An employee may or may not belong to a department.
• There are many employees in the organization with attributes of Employee ID, Name,
Phone Number, Address, Hire-Date, Age, and Sex.
• An employee can go on leaves and leave has two types: Casual leave and Paid leave
and leaves have attributes Leave Date, Leave Type, and Number of days.
• The record of children of employees is also to be recorded. The attributes for the
children are Children number, Sex, and Age.
• The employees supervise projects running in the organization and each project has
attributes Project ID, Project Name, Start Date, and Completion Date.
• The company has some Laboratories in it and every project is completed in some
Laboratory. (Solution is given in book)
Project 7
• Draw an E-R diagram for the following given CASE STUDY:
• Every employee has a unique number assigned by the firm, a name, and date of birth.
Each employee has a job title. Each employee does only one type of job at a time, and
we only need to retain information about an employee’s current job.
• There are 11 different departments in the firm, each with a unique name. An
employee can report to only one department. Each department has a phone number.
To procure (obtain) various types of equipment, each department deals with many
suppliers. A supplier typically supplies equipment to many departments. We need to
store the name and address of each supplier and the date of the last meeting between
a department and a supplier. Many employees can work on a project. An employee
can work on many projects, but can only be assigned to at most one project. Project
information that is stored in the database are project No, project name, project cost,
and duration.
(Solution is given in book)
Project 8
• Consider a company which prepares Products by importing different Items
from different Suppliers in foreign countries, through shipment. The prepared
products are sold to different local Customers through their purchase Orders.
• Point out the main entities and construct an ER diagram for this company’s
database.
Project 9
• Draw an E-R diagram for the following given CASE STUDY:
• A large bank operates several divisions. Information Technology (IT) is operated as one
of these divisions. Within the IT division are many departments that are managed by
one manager, and all IT employees belong to one of these departments. The IT
division assigns it’s employees to one or more ongoing projects in the bank. A project
may be planned/ but not have any employees assigned to it for several months. Each
project will have a single employee assigned who acts as a project leader.
(Solution is given in book)
Project 10
• Draw an E-R diagram for the following given CASE STUDY:
• Emerging Electric wishes to create a database with the following entities and
attributes:
• CUSTOMER with the attributes Customer ID, Name, Address (Street, City, State, Zip Code), and
Phone-No
• LOCATION with the attributes Location ID, Name, Address (Street, City, State, Zip Code), and Type
(values of Business or Residential)
• RATE with the attributes Rate-Class and Rate-Per-KWH (KWH stands Kilo Watt Hour)
• After interviews with the owners, you have come up with the following business rules:
• A customer can have one or more locations.
• Each location can have one or more rates, depending on the time of day.
(Solution is given in book)
Project 11
• Draw an E-R diagram according to the following CASE STUDY. You can make your
own assumptions if needed. After identifying Entity types, some attributes are
given, others can be added according to your assumptions.
CASE STUDY
• A company "Ashan Corporation" deals in selling products to its customers after purchasing
products from different vendors. Vendors have attributes like VendorID, VenderName,
Address, and Phone.
• The company sends a purchase order to a vendor and provides a list of items to be purchased
by the company.
• An item (product) may be purchased from different vendors.
• Items are stored in the stock after they are received from the vendor.
• Customers send sale orders with a list of products to buy from the Ashan Corporation
company.
• Products are sent to customers with the invoice after receiving sale orders from customers.
Invoice has attributes Invoice-No, Date, etc.
• Customers make the payments according to the invoice after receiving the invoice and make
payments on some date.
Project 12
• Draw an E-R diagram according to the following requirements:
• A company has different employees. The attributes of EMPLOYEE include Emp_ID,
Emp_Name, Emp_Address, and Emp_DOB. The employees work on different projects.
The attributes of PROJECT are Project_ID, Project_Name, and Project_Start_Date.
Each employee may be assigned to one or more projects or may not be assigned to
any project. A project must have at least one employee assigned or may have any
number of employees assigned to it. An employee’s billing rate may vary by one
project to another. The company wishes to record the project billing rate for each
employee when assigned to a particular project.

(Solution is given in book)


Project 13
• Draw an E-R diagram according to the following requirements:
• A customer places or may place orders to a company. A regular customer places orders
at regular intervals. An order is placed by one customer only, so two or more customers
cannot place an order jointly. Note that some customers may not have placed an order
yet. A customer can operate at a number of sites. The delivery address is included in the
customer order.
• Each order will request product items. Most orders will request several product items,
and order must request at least one product item into specific categories (e.g. Beans,
Cereals, Pet Food, etc.). A particular item may be requested on several orders. Product
items are organized into product types. Each product item will be of a specific type.
Product types organize product item that is supplied by a single supplier and suppliers
may supply several different product types.
• Each order consists of a number of requests for items, known as order items. Each order
will have at least one order item. Most orders will consist of many order items. Each
order item relates to a particular product item that has been requested. A product item
can be requested in several orders.
Project 14
• A hospital may have many wards each with a unique code and name. Each ward may
have many beds and each bed is assigned a unique bed number. Similarly, each ward
may have many nurses. Each nurse has a unique code and other particulars. There
are also many physicians in the hospital. When a patient is admitted to the hospital,
a unique code is assigned to it and his/her name, address, date of birth, and other
particulars are recorded. In the hospital:
• A patient is assigned a particular ward. A single ward may be assigned to many patients during
a given period.
• A ward may have one or many nurses. Each nurse is assigned a single ward.
• A physician may check zero or many patients during a given period. A patient may be checked
by zero or many physicians.
• After a particular patient is discharged from the hospital, he/she has to pay the bill for the
medicines.
Project 15
• Draw an E-R diagram for the following given CASE STUDY and take your own
assumptions (if needed):
• Hospitals are essential part of our lives providing the best medical facilities to people
suffering from different ailments (diseases). It is necessary for the hospitals to keep track of
its day to day record of its patients, doctors, nurses, and other medical staff that keep the
hospital running successfully and smoothly.
• But keeping the track of all the activities and their records on the paper is very cumbersome
and error-prone. It is also a very inefficient and time taking process. A hospital consists of
different departments each supervised by one head, each department has its own unique
name and location. Each department offers its services to various patients. The record of the
patient is to be kept for future purposes. Hospital has its own laboratory and medical
pharmacy for quick response in some critical situations. Here are some Pin points about the
hospital:
• A hospital provides medical services to the patients.
• The patients are categorized into IN Patient and OUT Patient.
• Each patient is assigned a unique ID.
• The patient record keeps track of the diagnosis and information about the patient.
• At the time of discharge, the patient report is prepared.
Project 16
• Draw an E-R diagram for the following given CASE STUDY and take your own
assumptions (if needed):
• A General hospital consists of a number of specialized wards (such as Maternity,
Pediatric, Oncology, etc.). Each ward hosts a number of patients, who were admitted
on the recommendation of their own physician and confirmed by a consultant
employed by the hospital. On admission, the personal details of every patient are
recorded. A separate register is to be held to store the information of the tests
undertaken and the results of prescribed treatment. A number of tests may be
conducted for each patient. Each patient is assigned to one leading consultant but
may be examined by another doctor if required. Doctors are specialists in some
branches of medicine and may be leading consultants for a number of patients, not
necessarily from the same ward.
(Solution is given in book)
Project 17
• Consider a hospital’s environment where the following are the main
requirements:
• Every patient has a primary physician. Every doctor has at least one patient.
• Doctors prescribe drugs for patients. A doctor could prescribe one or more drugs for
several patients, and a patient could obtain prescriptions from several doctors.
• A drug could be sold at several pharmacies in the hospital. Each pharmacy sells several
drugs.
• A pharmacist can work for only one pharmacy. A pharmacy must have a manager.
• Design an ER model for this environment.
(Solution is given in book)
Project 18
• Draw an E-R diagram according to the following requirements:
• A hospital has a large number of physicians. The attributes of PHYSICIAN include
Physician_ID, Physician_Name, Physician_Cell_No, and Physician_Specialty. The
patients are admitted to the hospital by a physician. The attributes of the PATIENT are
Patient_ID, Patient_Name, and Patient_Address. A physician may admit many patients
or may not admit any patient. A patient must be admitted by a physician. An admitted
patient is treated by one or more physicians. A physician may treat many patients or
may not treat any patient. Whenever a patient is treated by a particular physician, the
hospital records the details of the treatment. The components of the treatment detail
include Date, Time, and Result.

(Solution is given in book)


Project 19
• Draw an E-R diagram according to the following requirements:
• A laboratory has different chemists who work on projects. A chemist may be assigned
many projects or may not be assigned any project. He/she may be assigned many
types of equipment for each project or may not be assigned any equipment. A project
must be assigned to at least one chemist and may be assigned many equipments or
may not be assigned any equipment. An equipment must be assigned to a particular
chemist and may be assigned to many projects or may not be assigned to any project.
The attributes of CHEMIST are Chemist_ID, Chemist_Name, and Chemist_Cell_No. The
attributes of PROJECT are Project_ID, and Project_ Start_Date. The attributes of
EQUIPMENT are Equipment_ID and Equipment_Name. The laboratory wishes to keep
record about date when an equipment was assigned to a particular chemist working
on a specific project.
(Solution is given in book)
Project 20
• Draw an E-R diagram according to the following requirements:
• A system which can deal with the Purchasing of medicine for Store.
• Maintain their Stock giving alerts when the stock is about to finish for any medicine.
• The system has to track all of the Sales.
• All medicines must be sold with a doctor’s prescription and the system must track
such customers and their prescriptions.
Project 21
• Draw an E-R diagram for the given CASE STUDY.
CASE STUDY
• Islamia University Bahawalpur operates a fleet of 20 buses that serve approximately
3,000 students. The bus operation involves 20 regular routes, plus special routes for
activities, athletic events, and summer sessions. The University employs 12 full-time
drivers and 10 to 15 part-time drivers. A dispatcher coordinates the staffing and routes
and relays messages to drivers regarding students and parents who call drop-off
arrangements. Each payment is required to be generated to one customer.

(Solution is given in book)


Project 22
• Draw an E-R model according to the following requirements and take your
own assumptions (if needed):
• A Road Tour Bus Company owns a number of buses. Each bus is allocated to a
particular route, although some routes may have several busses. Each route passes
through a number of towns. One or more drivers are allocated to each stage of a
route, which corresponds to a journey through some or all of the towns on a route.
Some of the towns have a garage where busses are kept and each of the busses is
identified by the registration number and can carry different numbers of passengers
since the vehicles vary in size and can be single or double-decked. Each route is
identified by a route number and information is available on the average number of
passengers carried per day for each route. Drivers have an employee number, name,
address, and sometimes a telephone number.

(Solution is given in book)


Project 23
• Draw an E-R diagram according to the following requirements and take your own
assumptions (if needed):
• A database is to be designed for a Vehicle Management System. The information required includes a
description of Vehicle, subcontractors (i.e. garages), company expenditures, company revenues, and
customers. The vehicle is to be described by such data as: make, model, year of production, engine
size, fuel type, number of passengers, registration number, purchase price, purchase date, rent price,
and insurance details. It is the company policy not to keep any vehicle for a period exceeding one
year. All major repairs and maintenance are done by subcontractors (i.e. franchised garages), with
whom the company has long term agreements. Therefore, the data about garages to be kept in the
database includes garage names, addresses, range of services, and the like. Some garages require
payments immediately after a repair has been made; with other companies has made arrangements
for credit facilities. Company expenditures are to be registered for all outgoings connected with
purchases, repairs, maintenance, insurance, etc. Similarly, the cash inflow coming from all sources –
vehicle hire, vehicle sales, insurance claims – must be kept of file. The system maintains a reasonably
stable client base. For this privileged category of customers special credit card facilities are provided.
These customers may also book in advance a particular vehicle. These reservations can be made for
any period of time up to one month. Casual customers may pay a deposit for an estimated time of
rental unless they wish to pay by credit card. All major credit cards are accepted. Personal details
(such as name, address, telephone number, driving license, number) about each customer are kept in
the database.
Project 24
• Consider Sethi Motors’ company which deals in sales and service of cars.
Following are the main considerations in this company:
• The company has two types of employees: Salesmen and Mechanics.
• A salesman sells cars to different Clients.
• A mechanic repairs the cars sold to different Clients.
• All the activities of sales and repairs are recorded in the company’s log book.
• Point out the main entities and their attributes. Moreover, construct an ER
diagram for this company’s database.
(Solution is given in book)
Project 25
• Suppose you are given the following requirements for a simple database for
the Pakistan Cricket Board (PCB) teams:
• The PCB has many registered local teams of different cities.
• Each team has a name, a city, a coach, a captain, and a set of players.
• Each player belongs to only one team.
• Each player has a name, a type (such as batsman, bowler or wicket-keeper), a skill
level, and a set of injury records.
• A team captain is also a player.
• A game is played between two teams (referred to as host_team and guest_team) and
has a date (such as May 11th, 2020) and a result (such as completed, drawn,
discarded, etc.).
• Construct a clean and concise ER diagram for the PCB database. List your
assumptions and clearly indicate the cardinality mappings as well as any role
indicators in your ER diagram.
(Solution is given in book)
For more details, refers to

PM Series

Database Management

by
CM Aslam, Aqsa Aslam, Mudassir
Ahmad & Hafiz Saeed Ahmad

Publisher: Majeed Sons


22- Urdu Bazar, Lahore

You might also like