DBMS (R20) UNIT - 3.docx
DBMS (R20) UNIT - 3.docx
Syllabus:
3.1Introduction
Requirements Analysis
We must implement our database design and convert the conceptual database
design into a database schema (a description of data) in the data model (a
collection of high-level data description constructs that hide many low-level
storage details) of the DBMS. We will consider only relational DBMSs, and
therefore, the task in the logical design step is to convert the conceptual
database design in the form of E-R Schema (Entity-Relationship Schema)
into a relational database schema.
Schema Refinement
The fourth step in database design is to analyze the collection, of relations (tables) in
our relational database schema to identify future problems, and to refine (clear) it.
DATABASE MANAGEMENT SYSTEMS UNIT – III : ER
MODEL
This step may simply involve building indexes on some tables and clustering
some tables, or it may involve redesign of parts of the database schema
obtained from the earlier design steps.
Any software project that involves a DBMS must consider applications that
involve processes and identify the entities.
Types of attributes:
⮚ Simple attribute − Simple attributes are atomic values, which cannot be
⮚ Derived attribute − Derived attributes are the attributes that do not exist
in the physical database, but their values are derived from other attributes
present in the database. For example, average_salary in a department
should not be saved directly in the database, instead it can be derived. For
another example, age can be derived from data_of_birth.
values. For example, a person can have more than one phone number,
email_address, etc.
▪ Unary = degree 1
▪ Binary = degree 2
DATABASE MANAGEMENT SYSTEMS UNIT – III : ER
MODEL
▪ Ternary = degree 3
▪ n-array = degree
Unary Relationship: A relationship with one entity set. It is like a
relationship among 2 entities of same entity set. Example: A professor (
in-charge) reports to another professor (Head Of the Dept).
Cardinality:
Defines the number of entities in one entity set, which can be associated with
the number of entities of other set via relationship set. Cardinality ratios are
categorized into 4. They are.
Participation Constraints:
⮚ Total Participation − If Each entity in the entity set is involved in the
relationship then the participation of the entity set is said to be total. Total
participation is represented by double lines.
⮚ Partial participation − If, Not all entities of the entity set are involved in
the relationship then such a participation is said to be partial. Partial
participation is represented by single lines.
Example:
Departments entity sets such that each department has at most one manager,
although a single employee is allowed to manage more than one department.
The restriction that each department has at most one manager is an example of
a key constraint, and it implies that each Departments entity appears in at
most one Manages relationship in any allowable instance of Manages. This
restriction is indicated in the ER diagram of below Figure by using an arrow
from Departments to Manages. Intuitively, the arrow states that given a
Departments entity, we can uniquely determine the Manages
Below figure show a ternary relationship with key constraints. Each employee
works in at most one department, and at a single location.
Weak Entities
Strong Entity set: If each entity in the entity set is distinguishable or it has a
key then such an entity set is known as strong entity set.
Weak Entity set: If each entity in the entity set is not distinguishable or it
doesn't has a key then such an entity set is known as weak entity set.
eno is key so it is represented by solid underline. dname is partial key. It can't
distinguish the tuples in the Dependent entity set. so dname is represented by
dashed underline.
Weak entity set is always in total participation with the relation. If entity set is
weak then the relationship is also known as weak relationship, since the
dependent relation is no longer needed when the owner left.
Ex: policy dependent details are not needed when the owner (employee) of
that policy left or fired from the company or expired. The detailed ER
Diagram is as follows.
Now we are in a position to write the ER diagram for the Company database
which was introduced in the beginning of this unit. The readers are strictly
advised to follow the steps shown in this unit to design an ER diagram for any
chosen problem.
After careful analysis of the problem we come to a conclusion that there are
four possible entity sets as shown below:
1.Employees Strong Entity Set
2.Departments Strong Entity Set
3.Projects Strong Entity Set
4.Dependents Weak Entity Set
The next step is to get all the attributes that are most applicable for each entity
set. Do this work by considering each entity set in mind and also the type of
attributes. Next job is to pick the primary key for strong entity sets and partial
key for weak entity sets.
The underlined attributes are the primary keys and DepName is the partial
key of Dependents. Also, DLocation may be treated as a multivalued
attribute.
In this step we need to find all the meaningful relationship sets among
possible entity sets. This step is very tricky, as redundant relationships may
lead to complicated design and in turn a bad implementation.
Example: Let us show below what the possible relationship sets are:
1.Employees and Departments WorksFor
2.Employees and Departments Manages
3.Departments and Projects Controls
4. Projects and Employees WorksOn
5.Dependents and Employees Has
6.Employees and Employees Supervises
Some problems may not have recursive relationship sets but some do have. In
fact, our Company database has one such relationship set called Supervises.
You can complete this step adding possible descriptive attributes of the
relationship sets (Manages has StartDate and WorksOn has Hours).
This step is relatively a simple one. Simply apply the business rules and
your common sense. So, we write the structural constraints for our example
as follows:
The last step is to look for “is-a” and “has-a” relationships sets for the
given problem. As far as the Company database is concerned, there are no
generalization and aggregation relationships in the Company database.
The complete single ER diagram by combining all the above five steps is shown in figure
3.8Class Hierarchies
To classify the entities in an entity set into subclass entity is known as class
hierarchies. Example, we might want to classify Employees entity set into
subclass entities Hourly-Emps entity set and Contract-Emps entity set to
distinguish the basis on which they are paid. Then the class hierarchy is
illustrated as follows.
This class hierarchy illustrates the inheritance concept. Where, the subclass attributes ISA
(read as
: is a) super class attributes; indicating the “is a” relationship (inheritance
concept).Therefore, the attributes defined for a Hourly-Emps entity set are the attributes
of Hourly-Emps plus attributes of Employees (because subclass can have superclass
properties). Likewise the attributes defined for a Contract-Emps entity set are the
attributes of Contract-Emps plus attributes of Employees.