Академический Документы
Профессиональный Документы
Культура Документы
2.1 INTRODUCTION
Data model is used to describe data, data relationship and constraints on data. A number
of different data models have proposed. They can broadly be classified into two
categories:
Object-based logical models.
Record-based logical models.
The object-based model can be defined as a collection of conceptual tools for describing
data, data relationships, and data constraints. The record-based model describes the data
structures and access techniques of a DBMS. There are various different object-based
models. Some of the more popular ones are:
The entity-relationship model
The binary model
The infological model
The semantic model
Of these, the most widely used one is the Entity-Relationship Model. It has gained
acceptance as the ideal data model for database design. This model was introduced by
Peter Chen in 1976, and since then it has been reformed by several persons. The entity
relationship model (E R Model) is based on a perception of real world that is made up
of a collection objects or entities and the relationship among these.
Conceptual Model
Before going to explaining the entity-relationship model, we will briefly discuss database
design. Database design involves designing the conceptual design model of the database.
The conceptual model reflects the entities and their relationships, based on the data
processing needs of the organization. This can be considered equivalent to the conceptual
level.
The conceptual model is a communication tool between the various users of the data. It
is developed without any concern for physical representation. The conceptual model is
used to organize, visualize, plan and communicate ideas. It is independent of the database
management system. Before actually implementing the database, the conceptual model
is designed. At this stage, requirements of all the users are considered to decide upon the
actual data to be stored in the system. This conceptual model is then mapped to the DBMS
that is actually to be used.
Data analysis is the first step in designing a conceptual model. Data analysis begins with
collecting information about the data. This usually involves using a questionnaire or a
similar method to obtain a list of data that the organization needs. Existing forms, bills,
reports are starting points for data collection. The data analysis involves identifying
entities, their attributes, and the relationships between attributes. The E-R Model is a way
to form and represent the conceptual model of database design
2.2.5.1 Superkey
An attribute, or group of attributes, that is sufficient to distinguish every tuple in the
relation from every other one. Each super key is called a candidate key
2.2.5.2 Candidate key
A candidate key is any set of one or more columns whose combined value is unique
through out that table. Since a null value is not guaranteed to be unique, no component
of a candidate key is allowed to be null. There can be number of candidate keys in a
table.
2.2.5.3 Primary key
The primary key of any table is any candidate key of that table which the database
designer arbitrarily designates as primary. The primary key may be selected for
convenience, comprehension, performance or any other reasons. Every entity must have
a primary key. The primary key is an attribute or combination of attributes that uniquely
identifies an instance of the entity. In other words, no two instances of an entity may
have the same value for the primary key. Sometimes it is useful to use more than one
attribute to form a primary key. When a primary key for an entity is made up of more
than one attribute the key is called a composite key. The terms composite key is also
used to describe primary keys that contain multiple attributes. When dealing with a
composite primary key it is important to understand that it is the combination of values
for all attributes that must be unique. It is not necessary for each attribute in the key to
be unique. For example, the entity ENROLLMENT has a composite primary key
comprised of the attributes STUDENT_ID and COURSE_ID. Each instance of
ENROLLMENT must contain a unique combination of values for StudentID and
CourseID. However, there can be duplications of StudentID or CourseID. So, it is
possible for many instances of ENROLLMENT to have the value MIS100 for
CourseID, but each of those instances must contain different values for StudentID.
P1
C1
P2
C2
P3
C3
P4
C4
PERSON
CHAIR
Figure 2.3 One to One: One instance of entity type Person is related to one instance of
the entity type Chair.
One-to-Many (1:N) relationships A one-to-many (1:N) relationships is when for one
instance of entity A, there are zero, one, or many instances of entity B, but for one
instance of entity B, there is only one instance of entity A. For example a department
has many employees or each employee is assigned to one department.
E1
O1
O2
E2
E3
E4
O3
ORGANIZATION
E5
EMPLOYEE
Figure 2.4 One to Many: One instance of entity type Organization is related to
multiple instances of entity type Employee
E1
D1
E2
D2
E3
E4
D3
E5
EMPLOYEE
DEPARTMENT
Figure 2.5 Many to one: Multiple instance of employees is related to one instance of
department
Many-to-Many (M:N) relationship A many-to-many (M:N) relationship, sometimes
called non-specific, is when for one instance of entity A, there are zero, one, or many
instances of entity B and for one instance of entity B there are zero, one, or many
instances of entity A. For example employees can be assigned to no more than two
projects at the same time and projects must have assigned at least three employees.
Therefore a single employee can be assigned to many projects; conversely, a single
project can have assigned to it many employee. Here the cardinality for the relationship
between employees and projects is two and the cardinality between project and
employee is three.
S1
C1
S2
C2
S3
C3
S4
C4
STUDENT
COURSE
Figure 2.6 Many to many: Multiple instances of Student are related to multiple
instances of Course Entity.
2.2.6.3 Relationship Participation
Total : Every entity instance must be connected through the relationship to another
instance of the other participating entity types
Partial: All instances need not participate
E.g.: Employee and Head-of Department
Employee: partial
Department: total
All employees will not be head-of some department. So only few instances of employee
entity participate in the above relationship. But each department will be headed by some
employee. So department entitys participation is total and employee entitys
participation is partial in the above relationship
2.2.6.4 Existence
Existence denotes whether the existence of an entity instance is dependent upon the
existence of another, related, entity instance. The existence of an entity in a relationship
is defined as either mandatory or optional.
Mandatory :If an instance of an entity must always occur for an entity to be included in
a relationship, then it is mandatory. An example of mandatory existence is the statement
"every project must be managed by a single department".
Optional : If the instance of the entity is not required, it is optional. An example of
optional existence is the statement, "employees may be assigned to work on projects".
2. 3 ERD Modeling Notations:
Figure 2. 7 ER Modeling Notations
2. 4 Entity-Relationship Diagram: E-R Model describes data and identifies
relationship between them. E-R model is represented by E-R Diagram. In the following
sections, E-R model is explained along with their representation in E-R diagram
2.4.1 Attributes: Properties or characteristics possessed by an entity
Floor
Composite
Attribute
Street
Building
Address
DOB
Derived
attribute
Age
Name
Employee
E#
Skills
Multi valued
attribute
Key attribute
Figure 2.8: Type of attributes
Enrolls in
Student
Course
Employee
Manages
Employee
Works for
Department
Prescription
Doctor
Patient
Head of
Employee
Partial participation
Department
Total participation
Medicine
No. of Days
Dosage
Doctor
Prescription
Patient
Employee
Has
Dependents
Customer
Have
Account
Advisor
Advise
Student
Student
Take
Course
SECERATRY
ENGINEER
TEHCNICIAN
Each of these employee types is described by a set of attributes that includes all the
attributes of entity set employee plus possibly additional attributes. For example,
SECERATRY entities my be described further by the attribute TypingSpeed, whereas
TECHNICIAN entities may be described further by the attribute Tgrade and ENGINEER
entities may be described by EngType. The processof designating subgroupings within
an entity set is called specialization. The specialization of EMPLOYEE allow us to
Tonnage
Price
MaxSpeed
VehicleId
TRUCK
K
CAR
LicencePlacte No.
Figure 2. 20 (a)
LicencePlacte No.
VehicleId
Price
VehicleId
LicencePlacteNo
VEHICLE
ISA
MaxSpeed
Tonnage
NoOfPasseng
ers
NoOfAxle
s
CAR
TRUCK
Figure 2. 20(b)
Birthdate
Employeei
d
Address
Name
JobType
EMPLOYEE
ISA
TypingSpee
d
EngType
TGrade
SECRETARY
TECHNICIAN
ENGINEER
EMPLOYEE
ISA
CLASSIFIED
WAGES
ISA
FACULTY
STAFF
STUDENT
SALARIED_EMPLOYEE,
then
the
spcialization{HOURLY_EMPLOYEE,
SALARIED_EMPLOYEE} is a total specialization. (figure 2.23)
Partial specialization: In partial specialization some of higher-level entities may not
belong to any lower-level entity set. For example, if some EMPLOYEE entities do not
belong to any of the subclass {SECRETARY, ENGINEER, TECHNICIAN}, then that
specialization is partial.( Figure 2. 21)
Partial generalization is the default. We can specify total generalization in an E-R
diagram by using a double line to connect the box representing the higher-level entity
set to the triangle symbol.
The disjointedness and completeness constraints are independent. Therefore, we have
the following four possible constraints on specialization:
1) Disjoint, total
2) Disjoint, partial
3) Overlapping, total
4) Overlapping, partial
EMPLOYEE
ISA
HOURLY_EMPLOYEE
SALARIED_EMPLOYEE
and Address.
For the Loan Entity, the relevant attribute other than Loan# would be Loan
Type.
For the Account Entity, the relevant attribute other than Account No would be
Account Type.
For the Customer Entity, the relevant attributes other than Customer# would be
Name, Telephone# and Address.
Step 5: Draw complete E-R diagram with all attributes including
Figure 2.27
Floor
Street
Building
Date of
Joining
Address
Years of
Service
Name
Employee
E#
Skillset
Employee entity in the relationship HeadOf , because only one Employee can become
head of the department. But there is a total participation of Department entity because
every Department must have a head of department. Therefore the relational schema
would be
Employee(E#, Name.)
Department (Dept#, Name,., Head)
E#
Ename
DOB
Address
EMPLOYEE
ISA
BasicSal
NoOfHrs
HOURLY_EMPLOYEE
SALARIED_EMPLOYEE
EMPLOYEE
E#
PK
Ename
DOB
Address
HOURL_EMPLOYEE
E#
PK
NoOfHrs
SALARAIED_EMPLOYEE
E#
PK
BasicSal
Figure 2.49 Conversion of specialization to table
2) Weak Entity types are converted into a table of their own, with the primary key of
the strong Entity acting as a foreign key in the table. This Foreign key along with the
key of the Weak Entity form the composite primary key of this table.
Example: As per this guideline, a Branch table can be created with the
following structure.
BRANCH (BankCode, Branch#, Name, Address)
3) Each relationship can be defined as separate table in relational schema. Key
attributes of participating entities will become key attribute of the Relationship.
Example: We can define Loan_Detail table with Loan# and Customer# together as
primary key with other relevant attributes like DateOfSanction, InterestRate,
LoanAmount, Duration etc.
LOAN_DETAILS (Loan#, Customer#, DateofSanction, InterestRate,
LoanAmount, Duration)
Participating entities: The entities which are joined by the relation. In a Many to Many
relationship, it is necessary to create separate tables for participating entities and
relationships. In the banking application we have Customer and Loan Entities have a
Many to Many relationship. Hence one should create separate tables for
CUSTOMER
LOANS
LOAN_DETAILS.
SUMMARY
E-R Model is a conceptual data model used in mapping requirements of initial phase
into database design.
Conceptual model reflects the entities and their relationships, based on the data
processing needs of the organization
Entities are the people, places, things, events and concepts of interest to an organization
Properties or characteristics possessed by an entity are called as attributes
The set of possible values for an attribute is called the domain of the attribute
The attribute (or combination of attributes) that is unique for every entity instance is
called key attribute.
Entity that depends on other entity for its existence and doesnt have key
attribute of its own is called Weak Entity Set.
Attributes that can take many values for each entity instance are called multi-valued
attributes
Null value of an attribute is considered if that attribute does not have a value for a
particular entity
A Primary key uniquely identifies an entity in entity set. Keys that are eligible to
become primary key are called candidate Keys and the superset of candidate key is
called superkey.
A foreign key is a set of attribute(s) whose values are required to match values of a
candidate key in the same or another table
Relationship is the association between entities.
The degree of a relationship is the number of entities associated with the relationship.
Descriptive attribute is an attribute of a relationship exists between different entity
sets.
Mapping constraint specifies the association of entities in an entity set with other
entity set.
Participation constraint imposes constraints on participation of entities in the
specified relationship.
Specialization is the process of defining a set of subclasses of an entity type. It is a top
down approach.
Generalization is a reverse process of abstraction, which suppresses the differences
among several entity types. It is a bottom up approach.
Aggregation is an abstract concept for building composite objects from their
components.
REVIEW QUESTIONS
Q.1
Q.2.
Every airplane has a registration number and each airplane is of specific model.
(ii)
(iii)
A number of technicians work at airport who have eid, name, address, phone
number and salary of each technician. Each technician is an expert of one or more
plane models.
(iv)
Q.3.
Q.4.
Q.5.
Q.6.
Q.7
Q.8
Q.9
The airport has a number of tests that are used periodically to ensure that
airplanes are still worth. Each test has test number, a name and maximum
possible score.
Any weak entity set can be converted to strong entity set by simply adding appropriate
attribute. Why, then, do we have weak entity sets?
Discuss the naming conventions and symbols used in E-R diagram?
Design a generalization specialization hierarchy for a motor vehicle sales company. The
company sell Motorcycles, Cars, Vans and Buses. Justify the placement of attribute at
each level of hierarchy. Explain why they should not be placed at higher or lower level?
Design an E-R diagram that capture the following information about publisher-house
(i)
Every publisher has a publisher-id, name, mainoffice, phone number.
(ii)
Book have book-id, bname, subject, price and edition number.
(iii)
Author has author-id, name, specialized area, qualification.
(iv)
A publisher can publish many books. Similarly a book is published by only a
single publisher. Joint venture of publisher is restricted.
(v)
A publisher can hire the author to write the book or gave a job to the author.
Author write many books not restricted to a single publisher.
(vi)
Royalty given to each author is also recorded with the accordance of publisher.
In a university database, information on the following is to be
kept.
[Raj. Univ., 1998]
Faculty (name, dept, title, office, ext, email)
Staff (name, dept, job, ext, email)
Graduate (id, name, address, prev-degree, enrolled program)
Undergraduate (id, name, address, year, major)
TeachingAssistant (id, name, quarter, course)
Course (id, title, day, hour, room)
Reader (id, name, quarter, course, hour)
Review-section (course-id, TA, day, hour, room)
The following constraints apply:
Professors have a teaching assistant (TA) for each course they teach, TA must be a
graduate student. TAs hold review section for some course several reader can be
assigned to one course or review section. All students, TA and reader attend the course.
Develop an E-R diagram for above specification.
With the help of suitable example explain:
(i)
Key constraints.
[Raj. Univ., 1998, 2005]
(ii)
Strong and weak entity set
[Raj. Univ., 1998, 2005]
(iii)
Participation constraints
[Raj. Univ., 2003]
(iv)
Class Hierarchies
[Raj. Univ., 2003]
(v)
Aggregation
[Raj. Univ., 2003, 2005]
(vi)
Distributed database
[Raj. Univ., 2005]
(vii)
Cardinality
[Raj. Univ., 2005]
(viii) Candidate key
[Raj. Univ., 2005]
A software company manages a number of software projects. The company is organized
into many departments. Each department has unique id, name and manager. The company
has many employees. The company keeps track of id-number, name birth date, address,
joining date, leaving date, salary and department. An employee can be assigned many
software projects. Each project has unique id, name and machine. A project may be
jointly executed by more than one department. But all employee of a given department
may not be assigned to projects handled by the department. Each project has a project
Q.10
Q.11
Q.12
leader. Similarly projects are supervised by a group leader. Some of departments are non
technical. Draw an E-R diagram for above description.
[Raj. Univ., 1999]
A database is being constructed to keep track of teams and games of sports league. A
team has number of players, not all of whom participates in each game. It is desire to
keep track of all players participating in each game for each team, the position they played
in that game, and result of game. Design an E-R diagram.
[Raj. Univ., 2002]
Create an E-R diagram for each of following:
(i)
Each company operates four departments and each department belong to one
company.
(ii)
Each department employs one or more employee and each employee works for
one department.
(iii)
Each of employees in part (ii) may or may not have one or more dependents and
each dependent belongs to employee.
(iv)
Represent all E-R diagrams described in (i) (ii) and (iii) as single E-R
diagram.
[Raj. Univ., 2004]
What is the role of E-R model in Database design? Draw an E-R diagram for bank
management system.
[Raj. Univ., 2005]