0% found this document useful (0 votes)
58 views115 pages

Extraunit 1

Uploaded by

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

Extraunit 1

Uploaded by

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

MAHENDRA ENGINEERING COLLEGE

DEPARTMENT OF COMPUTER SCIENCE


AND ENGINEERING

DATABASE MANAGEMENT SYSTEMS

B. E II/CSE III Semester

UNIT-I PPT SLIDES


DATABASE MANAGEMENT SYSTEMS
SYLLABUS

• 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

• Relational Model Concepts –


Relational Algebra – SQL – Basic
Queries – Views – Constraints -
Embedded SQL - Database Design –
Functional Dependencies – Normal
Forms –1NF – 2NF- 3NF- BCNF - Join
Dependencies and Fifth Normal
Form.
UNIT III
TRANSACTION PROCESSING

• Transaction Processing – Properties


of Transactions - Serializability –
Transaction Support in SQL -Locking
Techniques – Time Stamp Ordering -
Recovery Concepts – Shadow Paging
– Log Based Recovery – Database
Security Issues.
UNIT IV
FILES AND INDEXING

• File Operations – Hashing Techniques


– Indexing – Single level and Multi-
level Indexes – B+ Tree –Static
Hashing - Query Processing
Overview – Algorithms for SELECT
and JOIN operations
UNIT V
SPECIAL DATABASES

• Distributed Databases: Architecture


– OODBMS – Object-Based
Databases - OO Data Model - OO
Languages –Object Relational
Databases - XML – Structure of XML
- Temporal Databases – Mobile
Databases.
TEXT BOOK :

• Abraham Silberschatz, Henry F. Korth and S. Sudharshan,


“Database System Concepts”, Sixth Edition, Tata Mc Graw
Hill, 2011.

• 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

The file system is software that manages


DBMS is software for managing the
and organizes the files in a storage medium
database.
within a computer.

Redundant data can be present in a file


In DBMS there is no redundant data.
system.

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 no efficient query processing in the Efficient query processing is there in


file system. DBMS.

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.

Cobol, C++ Oracle, SQL Server


OBJECTIVE TO LEARN DBMS
• To learn the fundamentals of data models and to represent
a database system using ER diagrams.
• To study SQL and relational database design.
• To understand the fundamentals of transaction processing
and query processing
• Familiarize with different types of files and indexing
techniques
• Understand the special databases
INDEX
UNIT-1 PPT SLIDES
S.NO Topics Covered
-------------------------------------------------------------------------------------
1. DBMS Application and DBMS Vs File Systems
2. Data Models
3. DBMS Architecture
4. Data Independence
5. Data Modeling using Entity – Relationship Model
6. Enhanced E-R Modeling
History of Database Systems
• 1950s and early 1960s:
– Data processing using magnetic tapes for storage
• Tapes provide only sequential access
– Punched cards for input
• Late 1960s and 1970s:
– Hard disks allow direct access to data
– Network and hierarchical data models in widespread
use
– Ted Codd defines the relational data model
• Would win the ACM Turing Award for this work
• IBM Research begins System R prototype
Magnetic tape Hard disk
Magnetic tape unit
History (cont.)
• 1980s:
– Research relational prototypes evolve into commercial systems
• SQL becomes industry standard
– Parallel and distributed database systems
– Object-oriented database systems
• 1990s:
– Large decision support and data-mining applications
– Large multi-terabyte data warehouses
– Emergence of Web commerce
• 2000s:
– XML and XQuery standards
– Automated database administration
– Increasing use of highly parallel database systems
– Web-scale distributed data storage systems
Database System Applications
• DBMS contains information about a particular enterprise
– Collection of interrelated data
– Set of programs to access the data
– An environment that is both convenient and efficient to use
• Database Applications:
– Banking: all transactions
– Airlines: reservations, schedules
– Universities: registration, grades
– Sales: customers, products, purchases
– Online retailers: order tracking, customized recommendations
– Manufacturing: production, inventory, orders, supply chain
– Human resources: employee records, salaries, tax deductions
• Databases touch all aspects of our lives
What Is a DBMS?

• A very large, integrated collection of inter


related data and a set of programs to access
those data..
• Models real-world enterprise.
– Entities (e.g., students, courses)
– Relationships (e.g., Madonna is taking
CS564)
• A Database Management System (DBMS) is a
software package designed to store and
manage databases.
Why Use a DBMS?

• Data independence and efficient


access.
• Reduced application development
time.
• Data integrity and security.
• Uniform data administration.
• Concurrent access, recovery from
crashes.
Why Study Databases?? ?

• A database, data is organized strictly in row and


column format. The rows are called Tuple or
Record.
• The data items within one row may belong to
different data types. On the other hand, the
columns are often called Domain or Attribute.
Purpose of Database Systems
• In the early days, database applications were built directly
on top of file systems
• Drawbacks of using file systems to store data:
– Data redundancy and inconsistency
• Multiple file formats, duplication of information in
different files
– Difficulty in accessing data
• Need to write a new program to carry out each new
task
– Data isolation — multiple files and formats
– Integrity problems
• Integrity constraints (e.g. account balance > 0)
• Hard to add new constraints or change existing ones
Purpose of Database Systems (Cont.)

• Drawbacks of using file systems (cont.)


– Atomicity of updates
• Failures may leave database in an inconsistent state
with partial updates carried out
• Example: Transfer of funds from one account to
another should either complete or not happen at all
– Concurrent access by multiple users
• Concurrent accessed needed for performance
• Uncontrolled concurrent accesses can lead to
inconsistencies
– Example: Two people reading a balance and
updating it at the same time
– Security problems
• Hard to provide user access to some, but not all, data
• Database systems offer solutions to all the above problems
Levels of Abstraction

• Physical level: The lowest level of abstraction describes


how the data are actually stored. (e.g., customer
• Logical level: The next-higher level of abstraction
describes what data are stored in the database, and what
relationships exist among those data..
type customer = record
customer_id : string;
customer_name : string;
customer_street : string;
customer_city : string;
end;
• View level: View level (or External View / Schema): The
highest level of abstraction describes only part of the
entire database. (such as an employee’s salary)
Summary
• DBMS used to maintain, query large datasets.
• Benefits include recovery from system crashes,
concurrent access, quick application development,
data integrity and security.
• Levels of abstraction give data independence.
• A DBMS typically has a layered architecture.
• DBAs hold responsible jobs
and are well-paid! 
• DBMS R&D is one of the broadest,
most exciting areas in CS.
View of Data

An architecture for a database system


Instances and Schemas

• Similar to types and variables in programming


languages
• Schema – the logical structure of the database (The
overall design of the database is called the database
schema.
– Example: The database consists of information
about a set of customers and accounts and the
relationship between them)
– Analogous to type information of a variable in a
program
– Physical schema: database design at the physical
level
– Logical schema: database design at the logical level
Instances and Schemas
• Instance – the actual content of the database
at a particular point in time (The collection of
information stored in the database at a
particular moment is called an instance of the
database.)
• Physical Data Independence – the ability to
modify the physical schema without changing
the logical schema
– Applications depend on the logical schema
– In general, the interfaces between the
various levels and components should be
well defined so that changes in some parts
do not seriously influence others.
2.Data Models

• A collection of tools for describing


– Data
– Data relationships
– Data semantics
– Data constraints
• Relational model
• Entity-Relationship data model (mainly for
database design)
• Object-based data models (Object-oriented and
Object-relational)
• Semi structured data model (XML)
• Other older models:
– Network model
– Hierarchical model
Data Models

• A data model Underlying the structure of a


database is the data model: a collection
of conceptual tools for describing data,
data relationships, data semantics, and
consistency constraints.
• A data model provides a way to describe
the design of a database at the physical,
logical, and view levels.
Data Models
• Entity Relationship Model
• Relational Model
• Hierarchical Model
• Network Model
• Object Oriented Model
Entity-Relationship Model

• Entity-Relationship (ER) Model is based


on the notion of real-world entities and
relationships among them.
• While formulating real-world scenario
into the database model, the ER Model
creates entity set, relationship set,
general attributes and constraints.
Entity-Relationship Model

• ER Model is best used for the


conceptual design of a database.
• ER Model is based on −
• Entities and their attributes.
• Relationships among entities.
Entity-Relationship Model

• Entity - An entity in an ER Model is a


real-world entity having properties
called attributes. Every attribute is
defined by its set of values
called domain. For example, in a
school database, a student is
considered as an entity. Student has
various attributes like name, age,
class, etc.
Entity-Relationship Model

• Entity
rrLi

Attributes

Relatio
nships
Entity-Relationship Model

• Relationship - The logical


association among entities is
called relationship. Relationships
are mapped with entities in various
ways. Mapping cardinalities define
the number of association between
two entities.
ADVANTAGES
• It is easy to develop relational model
using E-R Model.
• Disadvantages
• It is just used for database design
not for implementation.
Relational Model
• The relational model represents data
& relationships among data by a
collection of tables, each of which
has a number of columns with
unique names.
• Total Number of tuples- Cardinality
of the tables
• Total Number of Columns-Degree of
the table.
Relational Model
Advantages
• Structural Independence
• Conceptual Simplicity
• Design, implementation, maintenance &
Usage Ease.
• Greator Flexibility
Disadvantages:
• May have slower Processing
• Not as good for transaction process than
hierarchical & Network Model
Hierarchical Model:

• Hierarchical Model was the first


DBMS model. This model organizes
the data in the hierarchical tree
structure.
• The hierarchy starts from the root
which has root data and then it
expands in the form of a tree adding
child node to the parent node.
Hierarchical Model:
Features of a Hierarchical Model

• One-to-many relationship: The


data here is organized in a tree-like
structure where the one-to-many
relationship is between the data
types. Also, there can be only one
path from parent to any node.
• Parent-Child Relationship: Each
child node has a parent node but a
parent node can have more than one
child node. Multiple parents are not
allowed.
Features of a Hierarchical Model

• Deletion Problem: If a parent node


is deleted then the child node is
automatically deleted.
• Pointers: Pointers are used to link
the parent node with the child node
and are used to navigate between
the stored data.
Advantages of Hierarchical Model

• It is very simple and fast to traverse


through a tree-like structure.
• Any change in the parent node is
automatically reflected in the child
node so, the integrity of data is
maintained.
Disadvantages
• Complex relationships are not
supported.
• If a parent node is deleted then the
child node is automatically deleted.
Network Model
• This model is an extension of the
hierarchical model. It was the most
popular model before the relational
model. This model is the same as the
hierarchical model, the only
difference is that a record can have
more than one parent. It replaces
the hierarchical tree with a graph.
Network Model
• It replaces the hierarchical tree with
a graph. Example: In the example
below we can see that node student
has two parents i.e. CSE Department
and Library. This was earlier not
possible in the hierarchical model.
Network Model
Features of a Network Model

• Ability to merge more


Relationships
• Many paths
• Circular Linked List
Advantages of Network Model

• The data can be accessed faster as


compared to the hierarchical model. This
is because the data is more related in the
network model and there can be more
than one path to reach a particular node.
So the data can be accessed in many
ways.
• As there is a parent-child relationship so
data integrity is present. Any change in
parent record is reflected in the child
record.
Disadvantages of Network Model

• As more and more relationships need


to be handled the system might get
complex. So, a user must be having
detailed knowledge of the model to
work with the model.
• Any change like updation, deletion,
insertion is very complex.
Object-Oriented Data Model

• The real-world problems are more closely


represented through the object-oriented
data model. In this model, both the data
and relationship are present in a single
structure known as an object.
• It store audio, video, images, etc in the
database which was not possible in the
relational model. In this model, two are
more objects are connected through links.
Object-Oriented Data Model
3.Database Architecture

The architecture of a database systems is greatly influenced by


the underlying computer system on which the database is
running:
• Centralized
• Client-server
• Parallel (multiple processors and disks)
• Distributed
Overall System Structure
1.Database systems are partitioned into modules for different functions.
Some functions
(e.g. file systems) may be provided by the operating system.
2. Broadly the functional components of a database system are:
a. Storage Manger (Database Manager)
1. Storage manager is a program module that provides the interface between
the low-level data stored
in the database and the application programs and queries submitted to the
system.
2. The storage manager is responsible to the following tasks:
1. interaction with the file manager
2. efficient storing, retrieving and updating of data
3. The important components include:
a. File manager: It manages allocation of disk space and data structures
used to represent information on disk.
b. Database manager: It is the interface between low-level data and
application programs and queries.
c. Transaction manager: Transaction manager ensures that the database
remains in a consistent (correct) state despite system failures (e.g., power
failures and operating system crashes) and
transaction failures.
d. Authorization and integrity manger – It conducts integrity checks and
user authority to access data.
e. Buffer manger –It is critical part of DB and stores temporary data.
In addition, several data structures are required for physical system
implementation:
a. Data files: They store the database itself.
b. Data dictionary: It stores information about the structure of the
database. It is used heavily. Great emphasis should be placed on
developing a good design and efficient implementation of the dictionary. In
short, it stores metadata.
c. Indices: They provide fast access to data items holding particular
values.
b.Query Processor: It is one of the functional components of
DBMS. It translates statements in a query language into low-level
instructions the database manager understands. It may also attempt to find
an equivalent but more efficient form.
It contains following components:
a. DML compiler - It converts DDL statements to a set of tables containing
metadata stored in a data dictionary.
It also performs query optimization.
b. DDL interpreter – It interprets DDL statements and records definitions
into data dictionary.
c. Query evaluation engine – It executes low-level instructions generated by
In addition, several data structures are required for physical system
implementation:
a. Data files: They store the database itself.
b. Data dictionary: It stores information about the structure of the
database. It is used heavily. Great emphasis should be placed on
developing a good design and efficient implementation of the dictionary. In
short, it stores metadata.
c. Indices: They provide fast access to data items holding particular
values.
b.Query Processor: It is one of the functional components of
DBMS. It translates statements in a query language into low-level
instructions the database manager understands. It may also attempt to
find an equivalent but more efficient form.
It contains following components:
a. DML compiler - It converts DDL statements to a set of tables
containing metadata stored in a data dictionary.
It also performs query optimization.
b. DDL interpreter – It interprets DDL statements and records definitions
into data dictionary.
c. Query evaluation engine – It executes low-level instructions generated
by DML compiler.
Database Application Architectures

(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

• A DBMS has appropriate languages and interfaces


to express database queries and updates.
• Database languages can be used to read, store
and update the data in the database.
• Two classes of languages
– Procedural – user specifies what data is
required and how to get those data
– Declarative (nonprocedural) – user
specifies what data is required without
specifying how to get those data
• SQL is the most widely used query language
DATA BASE LANGUAGES
Data Definition Language (DDL)

• Data Definition Language (DDL)


• DDL standsfor Data Definition Langu
age. It is used to define database
structure or pattern.
• It is used to create schema, tables,
indexes, constraints, etc. in the
database.
DDL
• Here are some tasks that come under DDL:
• Create: It is used to create objects in the database.
• Alter: It is used to alter the structure of the
database.
• Drop: It is used to delete objects from the
database.
• Truncate: It is used to remove all records from a
table.
• Rename: It is used to rename an object.
• Comment: It is used to comment on the data
dictionary.
Data Manipulation Language (DML)

• DML stands for Data Manipulation Language. It is


used for accessing and manipulating data in a
database.
• Select: It is used to retrieve data from a database.
• Insert: It is used to insert data into a table.
• Update: It is used to update existing data within a
table.
• Delete: It is used to delete all records from a table.
• Merge: It performs UPSERT operation, i.e., insert or
update operations.
Data Control Language (DCL)

• 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)

• TCL is used to run the changes made


by the DML statement. TCL can be
grouped into a logical transaction.
• Commit: It is used to save the
transaction on the database.
• Rollback: It is used to restore the
database to original since the last
Commit.
Data Modeling using Entity
–Relationship Model
• Data modeling is a technique to
document a software system using
diagrams and symbols. It is used to
represent communication of data.
• The highest level of abstraction for
the data model is called the Entity
Relationship Diagram (ERD). It is a
graphical representation of data
requirements for a database.
Data Modeling using Entity
–Relationship Model
• Entity: An entity can be a real-world
object, For example, in a school
database, students, teachers,
classes, and courses offered can be
considered as entities.
• All these entities have some
attributes or properties that give
them their identity.
Data Modeling using Entity
–Relationship Model
• Relationship
Relationships are represented by
diamond-shaped box. Name of the
relationship is written inside the
diamond-box. All the entities
(rectangles) participating in a
relationship, are connected to it by a
line.
Mapping Cardinality Constraints

• Express the number of entities to which another


entity can be associated via a relationship set.
• Most useful in describing binary relationship sets.
• For a binary relationship set the mapping
cardinality must be one of the following types:
– One to one
– One to many
– Many to one
– Many to many
One to one

• An Entity A is associated with atmost


one entity in B & an entity B is
associated with atmost one entity in
A.

Customer Depo Account


sitor
One to Many
• An Entity A is associated with any no
of entities in B.An entity in B is
associated with atmost one entity in
A.

Customer Account
Dep
osit
Mapping Cardinalities

One to One to many


one
Note: Some elements in A and B may not be mapped to any
elements in the other set
Mapping Cardinalities

Many to one Many to many


Note: Some elements in A and B may not be mapped to any
elements in the other set
ER Model Basics

name
ssn lot

Employees

• Entity: Real-world object distinguishable from other


objects. An entity is described (in DB) using a set of
attributes.
• Entity Set: A collection of similar entities. E.g., all
employees.
– All entities in an entity set have the same set of
attributes. (Until we consider ISA hierarchies,
anyway!)
– Each entity set has a key.
– Each attribute has a domain.
ER Model Basics (Contd.)
name

ssn lot
since
name dname
ssn lot did budget Employees

super- subord
Employees Works_In Departments visor inate
Reports_To

• Relationship: Association among two or more entities. E.g.,


Attishoo works in Pharmacy department.
• Relationship Set: Collection of similar relationships.
– An n-ary relationship set R relates n entity sets E1 ... En;
each relationship in R involves entities e1 E1, ..., en En
• Same entity set could participate in different
relationship sets, or in different “roles” in same set.
Relationship Sets
• A relationship is an association among several
entities
Example:
Hayes depositor A-102
customer entityrelationship setaccount entity
• A relationship set is a mathematical relation among
n  2 entities, each taken from entity sets
{(e1, e2, … en) | e1  E1, e2  E2, …, en 
En}

where (e1, e2, …, en) is a relationship


– Example:
(Hayes, A-102)  depositor
Relationship Set borrower
Relationship Sets (Cont.)
• An attribute can also be property of a relationship set.
• For instance, the depositor relationship set between entity sets
customer and account may have the attribute access-date
Degree of a Relationship Set

• Refers to number of entity sets that


participate in a relationship set.
• Relationship sets that involve two entity
sets are binary (or degree two).
Generally, most relationship sets in a
database system are binary.
• Relationship sets may involve more than
two entity sets.
Degree of a Relationship Set
Example: Suppose employees of a bank
may have jobs (responsibilities) at
multiple branches, with different jobs at
different branches. Then there is a
ternary relationship set between entity
sets employee, job, and branch
• Relationships between more than two entity sets
are rare. Most relationships are binary. (More on
this later.)
Additional
since
features of the ER name dname
model
ssn lot did budget

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

Employees Manages Departments

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

Employees Policy Dependents


Weak Entity Sets
• An entity set that does not have a primary key is referred to
as a weak entity set.
• The existence of a weak entity set depends on the existence
of a identifying entity set
– it must relate to the identifying entity set via a total, one-
to-many relationship set from the identifying to the weak
entity set
– Identifying relationship depicted using a double diamond
• The discriminator (or partial key) of a weak entity set is the
set of attributes that distinguishes among all the entities of a
weak entity set.
• The primary key of a weak entity set is formed by the primary
key of the strong entity set on which the weak entity set is
existence dependent, plus the weak entity set’s discriminator.
Weak Entity Sets (Cont.)
• We depict a weak entity set by double rectangles.
• We underline the discriminator of a weak entity set with a
dashed line.
• payment_number – discriminator of the payment entity set
• Primary key for payment – (loan_number, payment_number)
Weak Entity Sets (Cont.)

• Note: the primary key of the strong entity set is


not explicitly stored with the weak entity set,
since it is implicit in the identifying relationship.
• If loan_number were explicitly stored, payment
could be made a strong entity, but then the
relationship between payment and loan would be
duplicated by an implicit relationship defined by
the attribute loan_number common to payment
and loan
More Weak Entity Set Examples

• In a university, a course is a strong entity and a


course_offering can be modeled as a weak entity
• The discriminator of course_offering would be semester
(including year) and section_number (if there is more than one
section)
• If we model course_offering as a strong entity we would model
course_number as an attribute.
Then the relationship with course would be implicit in the
course_number attribute
ISA (`is a’) Hierarchies
name
 As in C++, or other PLs, ssn lot

attributes are inherited.


 If we declare A ISA B, Employees

every A entity is also hourly_wages hours_worked


considered to be a B ISA
contractid
entity.
Contract_Emps
Hourly_Emps

• Overlap constraints: Can Joe be an Hourly_Emps as well as a


Contract_Emps entity? (Allowed/disallowed)
• Covering constraints: Does every Employees entity also have to
be an Hourly_Emps or a Contract_Emps entity? (Yes/no)
• Reasons for using ISA:
– To add descriptive attributes specific to a subclass.
– To identify entitities that participate in a relationship.
Aggregation
• Used when we have to name
ssn lot
model a relationship
involving (entitity sets Employees
and) a relationship set.
– Aggregation allows
us to treat a Monitors until
relationship set as
an entity set for
purposes of started_on since
dname
participation in pid pbudget did
(other) budget
relationships. Projects Sponsors Departments

 Aggregation vs. ternary relationship:


Monitors is a distinct relationship, with a descriptive attribute.
 Also, can say that each sponsorship is monitored by at most one

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

• If each policy is name


owned by just 1 ssn lot pname age
employee, and Employees Dependents
Covers
each dependent
is tied to the Bad design Policies
covering policy,
first diagram is policyid cost
inaccurate. name pname age
ssn lot
• What are the
additional Dependents
Employees
constraints in
the 2nd Purchaser
Beneficiary
diagram?
Better design Policies

policyid cost
Binary vs. Ternary Relationships (Contd.)

• Previous example illustrated a case when two binary


relationships were better than one ternary relationship.
• An example in the other direction: a ternary relation
Contracts relates entity sets Parts, Departments and
Suppliers, and has descriptive attribute qty. No
combination of binary relationships is an adequate
substitute:
– S “can-supply” P, D “needs” P, and D “deals-with” S
does not imply that D has agreed to buy P from S.
– How do we record qty?
Summary of Conceptual Design

• Conceptual design follows requirements analysis,


– Yields a high-level description of data to be stored

• ER model popular for conceptual design


– Constructs are expressive, close to the way people think
about their applications.
• Basic constructs: entities, relationships, and attributes (of
entities and relationships).
• Some additional constructs: weak entities, ISA hierarchies,
and aggregation.
• Note: There are many variations on ER model.
Summary of ER (Contd.)

• Several kinds of integrity constraints can be expressed in the


ER model: key constraints, participation constraints, and
overlap/covering constraints for ISA hierarchies. Some foreign
key constraints are also implicit in the definition of a
relationship set.
– Some constraints (notably, functional dependencies) cannot
be expressed in the ER model.
– Constraints play an important role in determining the best
database design for an enterprise.
Summary of ER (Contd.)

• ER design is subjective. There are often many ways to


model a given scenario! Analyzing alternatives can be
tricky, especially for a large enterprise. Common choices
include:
– Entity vs. attribute, entity vs. relationship, binary or n-
ary relationship, whether or not to use ISA hierarchies,
and whether or not to use aggregation.
• Ensuring good database design: resulting relational
schema should be analyzed and refined further. FD
information and normalization techniques are especially
useful.
6.Enhanced ER-Diagram
• Today the complexity of the data is increasing so it
becomes more and more difficult to use the traditional ER
model for database modeling.
• To reduce this complexity of modeling we have to make
improvements or enhancements to the existing ER model
to make it able to handle the complex application in a
better way.
• Enhanced entity-relationship diagrams are advanced
database diagrams very similar to regular ER diagrams
which represent requirements and complexities of complex
databases.
• It is a diagrammatic technique for displaying the Sub Class
and Super Class; Specialization and Generalization; Union
or Category; Aggregation etc.
Generalization and
Specialization
• Specialized classes are often
called subclass while a generalized
class is called a superclass.
• A sub-class is best understood
by “IS-A analysis”.
• Ex:“Technician IS-A Employee”,
“Laptop IS-A Computer”.
Generalization/specialization
• A technician is a special Employee in
a university system Faculty is a
special class of Employees.
• Employee is a generalized entity
class while the Technician and
Faculty are specialized classes of
Employee.
EXAMPLE
E-R DIAGRAM FOR EXAMPLE
SUMMARY
UNIT-1 Covers Introduction to DBMS
1.It gives comparison of File Systems Versus
Database Systems –
2.Data Models
3.DBMS Architecture
4.Data Independence
5.Data Modeling using Entity Relationship
Model –
6.Enhanced E-R Modeling.

You might also like