Extraunit 1
Extraunit 1
• UNIT I -INTRODUCTION
• File Systems Versus Database
Systems – Data Models – DBMS
Architecture – Data Independence –
Data Modeling using Entity –
Relationship Model – Enhanced E-R
Modeling.
UNIT II
DATABASE DESIGN
• REFERENCES:
• Ramez Elmasri and Shamkant B. Navathe,
“Fundamentals of Database Systems”, Fifth Edition,
Pearson Education, 2008.
• Raghu Ramakrishnan, ―Database Management Systems‖,
Fourth Edition, McGraw-Hill College Publications, 2015.
File System DBMS
It doesn’t provide backup and recovery of It provides backup and recovery of data
data if it is lost. even if it is lost.
There is less data consistency in the file There is more data consistency because of
system. the process of normalization.
File systems provide less security in DBMS has more security mechanisms as
comparison to DBMS. compared to file systems.
Only one user can access data at a time. Multiple users can access data at a time.
• Entity
rrLi
Attributes
Relatio
nships
Entity-Relationship Model
(web browser)
Old Modern
4.Data Independence
• Applications insulated from how data
is structured and stored.
• Logical data independence: Protection
from changes in logical structure of
data.
• Physical data independence:
Protection from changes in physical
structure of data.
One of the most important benefits of using a DBMS!
DATA BASE LANGUAGES
• DCL stands
for Data Control Language. It is used
to retrieve the stored or saved data.
• Grant: It is used to give user access
privileges to a database.
• Revoke: It is used to take back
permissions from the user.
Transaction Control Language (TCL)
Customer Account
Dep
osit
Mapping Cardinalities
name
ssn lot
Employees
ssn lot
since
name dname
ssn lot did budget Employees
super- subord
Employees Works_In Departments visor inate
Reports_To
Key Constraints
Employees Manages Departments
• Consider Works_In:
An employee can
work in many
departments; a dept
can have many
employees.
• In contrast, each dept
has at most one
manager, according
to the key
constraint on 1-to-1 1-to Many Many-to-1 Many-to-Many
Manages.
Participation Constraints
• Does every department have a manager?
– If so, this is a participation constraint: the participation
of Departments in Manages is said to be total (vs.
partial).
• Every Departments entity must appear in an
instance of the Manages relationship.
since
name dname
ssn lot did budget
Works_In
since
Weak Entities
• A weak entity can be identified uniquely only by considering the
primary key of another (owner) entity.
– Owner entity set and weak entity set must participate in a
one-to-many relationship set (one owner, many weak entities).
– Weak entity set must have total participation in this
identifying relationship set.
name
cost pname age
ssn lot
employee.
Aggregation
Consider the ternary relationship works_on, which we
saw earlier
Suppose we want to record managers for tasks
performed by an employee at a branch
Aggregation (Cont.)
• Relationship sets works_on and manages represent
overlapping information
– Every manages relationship corresponds to a works_on
relationship
– However, some works_on relationships may not
correspond to any manages relationships
• So we can’t discard the works_on relationship
• Eliminate this redundancy via aggregation
– Treat relationship as an abstract entity
– Allows relationships between relationships
– Abstraction of relationship into new entity
Aggregation (Cont.)
• Eliminate this redundancy via aggregation
– Treat relationship as an abstract entity
– Allows relationships between relationships
– Abstraction of relationship into new entity
• Without introducing redundancy, the following diagram
represents:
– An employee works on a particular job at a particular
branch
– An employee, branch, job combination may have an
associated manager
E-R Diagram With Aggregation
Conceptual Design Using the ER Model
• Design choices:
– Should a concept be modeled as an entity or an
attribute?
– Should a concept be modeled as an entity or a
relationship?
– Identifying relationships: Binary or ternary?
Aggregation?
• Constraints in the ER Model:
– A lot of data semantics can (and should) be captured.
– But some constraints cannot be captured in ER
diagrams.
Entity vs. Attribute
• Should address be an attribute of Employees or an entity
(connected to Employees by a relationship)?
• Depends upon the use we want to make of address
information, and the semantics of the data:
• If we have several addresses per employee, address
must be an entity (since attributes cannot be set-
valued).
• If the structure (city, street, etc.) is important, e.g.,
we want to retrieve employees in a given city,
address must be modeled as an entity (since
attribute values are atomic).
Entity vs. Attribute (Contd.)
• Works_In4 does not
allow an employee to
from to
work in a department name dname
for two or more ssn lot did budget
periods.
• Similar to the Employees Works_In4 Departments
problem of wanting
to record several
addresses for an
employee: We want to
record several values
of the descriptive name dname
ssn lot did budget
attributes for each
instance of this Employees Works_In4 Departments
relationship.
Accomplished by
introducing new from Duration to
entity set, Duration.
Entity vs. Relationship
• First ER diagram OK if a
manager gets a separate since dbudget
name dname
discretionary budget for ssn lot did budget
each dept.
• What if a manager gets a Employees Manages2 Departments
discretionary budget
that covers all managed
depts? name
ssn lot
– Redundancy: dbudget
since dname
stored for each dept did
Employees budget
managed by manager.
– Misleading: Suggests
Manages2 Departments
dbudget associated ISA
with department-mgr
combination. This fixes the
Managers dbudget
problem!
Binary vs. Ternary Relationships
policyid cost
Binary vs. Ternary Relationships (Contd.)