Module 1
Module 1
Introduction To Database
Systems and E-R Model
By Jismy Joseph
Overview of Database Systems
Database
• A Database is a collection of interrelated data.
• Designed to meet the information needs of
an organization.
• Eg. A university Database – It contains information
about students, faculty, courses, classroom etc. It
could also contains the information about which
student is studying which course.
By Jismy Joseph
Database Example
StudentDetails
StudentID SName Address PhoneNo Course
By Jismy Joseph
Database Example
CourseDetails
CourseID CName CFees Level
1 MBA 28000$ 9
2 MCA 30000$ 9
By Jismy Joseph
A Historical Perspective
• The first general purpose DBMS, designed
by Charles Bachman at General electric in
the early 1960, was called the Integrated Data
store.
• It formed the basis for the network data
model, which was standardized by the Conference
on Data Systems Language (CODASYL).
• In the late 1960, IBM developed the
Information Management system(IMS) DBMS.
• IMS formed the basis of Hierarchical data
Model.
By Jismy Joseph
• In 1970, Edgar Codd, at IBM’s San Jose
research Laboratory, Proposed a new data
representation framework called relational
data model.
• In the 1980, The SQL query language for
relational databases, developed as part of
IBM System r Projects.
• The SQL was standardized in the late 1980s.
• The current standard SQL:1999 was adopted
by the American National Standards Institute
(ANSI) and International Organization
for Standardization (ISO).
By Jismy Joseph
Advantages of a DBMS
Efficient Data Access – DBMS utilizes different
techniques to store and retrieve data efficiently.
Data Independence – Application program should
not, ideally, be exposed to details of data
representation and storage. It provides a abstract
view of data that hides such details.
Data Integrity & Security – DBMS can enforce
integrity constraints.
Concurrent Access and Crash Recovery – DBMS
schedule concurrent accesses to the data. i.e. data
being accessed by one user at the same time.
DBMS also protect the users from the effect of the
system failures. By Jismy Joseph
Advantages of Database
Reduced Application Development time – DBMS supports
important functions that are common to many applications
accessing data in the DBMS.
It avoid data redundancy - Data redundancy means storing
the same data more than once. For eg. In a banking
software, there is a possibility of storing customer details
(ie customer name and phone no..) in more than one
table(saving account, current account). DBMS helps us to
avoid data redundancy problems.
It avoid data inconsistency - Data redundancy may lead to
data inconsistency. For eg. The customer’s address is
contained in more than one table. If the customer’s address
is changed, then the changes are reflected in one table but
not elsewhere. This situation leads to data inconsistency.
By Jismy Joseph
Disadvantages of DBMS
File-Based Systems
• Collection of application programs
that perform services for the end
users (e.g. reports).
• Each program defines and
manages its own data.
By Jismy Joseph
File-Based Processing
By Jismy Joseph
Limitations of File-Based Approach
• Data Redundancy and inconsistency – the
same information may be duplicated in several
places.
• Difficulty in accessing Data.
• Integrity Problem – the data values stored in
the database must satisfy certain types of
consistency constraints. When new constraints
are added, it is difficult to change the program
to enforce them.
By Jismy Joseph
Limitations of File-Based Approach
• Duplication of data
– Same data is held by different programs.
– Wasted space and potentially different values
and/or different formats for the same item.
By Jismy Joseph
Limitations of File-Based Approach
By Jismy Joseph
Limitations of File-Based Approach
• Data dependence
– File structure is defined in the program code.
By Jismy Joseph
The Relational Data Model
• In this model,the data is organized into
tables (ie., rows and columns). These
tables are called relations.
•A row in a table represents a
relationship among a set of values.
Consider a sample database with three
tables (relations):Suppliers, Items,
Quantities:
Suppliers (sup-no#,sup-name,status,
city)
Items ( item-no#, item-name, price)
Quantities By(sup-no#,
Jismy Joseph item-no#, Qty)
Suppliers
Sup-no# Sup-Name Status City
S1 Britannia 10 Delhi
S2 New 30 Mumbai
S3 Cockg 10 Delhi
Items
Item-no# Item-name Price
I1 Milk 15.00
I2 Cake 5.00
I3 Bread 9.00
I4 Biscuit 14.00
I5 Ice cream 6.00
I6 Jam 10.00
Quantities
Sup-no# Item-no# Qty
S1 I2 10
S1 I3 20
S1 I6 20
S2 I4 20
S2 I5 10
S3 I1 10
By Jismy Joseph
•Rows of relations are generally referred to
as tuples or records and the columns are
usually referred to as attributes or
field.
•No two tuples are identical and their
ordering is not important.
10 20 20 20 10 10
By Jismy Joseph
The Hierarchical Data Model
•Same as network model. The only difference is
that in the hierarchical model, records are
organized as trees rather than arbitrary
graphs.
•The record type at the top of the tree is
usually known as root.
•In general, the root may have any number of
dependents and each of these dependents may
have any number of low level dependents and
so on.
Consider the hierarchical view of the above
sample database of suppliers, items and
quantities. By Jismy Joseph
S1 Britannia 10 Delhi
I2 Cake 5
I3 Bread 9
10
I6 Jam 10
20
20
S2 New 30 Mumb
ai
I4 Biscuit 14
I5 Icecrea 6
m 20
10
S3 Cockg 10 Delhi
I1 Milk 15
10Joseph
By Jismy
In this tree structure supplier record type
is the root node.
•Here the relationship is expressed in the
form of a tree with all the edges pointing
to the leaf.
•The operations on a hierarchical database
are performed through a data manipulation
language for hierarchical data model.
•The various operations include retrieval,
insertions , deletions and modifications of
records.
By Jismy Joseph
DBMS ARCHITECTURE
By Jismy Joseph
DBMS ARCHITECTURE
The logical architecture deals with the way data is stored and
presented to users.
By Jismy Joseph
DBMS ARCHITECTURE
By Jismy Joseph
Levels of abstraction in a DBMS
By Jismy Joseph
Three Level Architecture of DBMS / Levels
of Abstraction in a DBMS
A major purpose of a database system is to provide
users with an abstract view of the data. That is, the
system hides certain details of how the data is
stored and maintained.
• External or View Level
• Conceptual Level
• Internal or Physical Level
By Jismy Joseph
Three Level Architecture of DBMS
continue…
External
View 1 View 2 View 3
Level
Conceptual
Level
Physical
Level
By Jismy Joseph
Three Level Architecture of DBMS
continue…
Sales Officer Inventory Controller
View 1 View 2
External Item_Name Item_Name
Level Price Stock
Conceptual
Conceptual Item_Number Character (6)
Item_Name Character(30)
Level Price Numeric(5,2)
Stock Numeric(4)
Physical
Stored_Item Length=50
Physical Item # Type = Byte(6), offset = 0, Index = Ix
Name Type = Byte(30), offset = 6
Level Price Type = Byte(8), offset = 36
Stock Type = Byte(4), offset = 44
By Jismy Joseph
Physical Level
• Lowest level of abstraction
• Describes how the data are actually stored.
• Describes low level data structures in detail.
Logical Level
• Describes what data are stored in the database,
What relationship exist among them.
• Database Administrator use the logical level of
abstraction.
View Level
• The highest level of abstraction describes only the
part of the entire database
By Jismy Joseph
External or View Level
By Jismy Joseph
External or View Level
continue…
By Jismy Joseph
External or View Level
continue…
By Jismy Joseph
Conceptual Level
continue…
By Jismy Joseph
Conceptual Level
continue…
By Jismy Joseph
Internal or Physical Level
By Jismy Joseph
Internal or Physical Level
By Jismy Joseph
Data Independence
The ability to modify a schema definition in one
level without affecting a scheme definition in the
next higher level is called DATA INDEPENDENCE
• Physical Data Independence
By Jismy Joseph
Physical Data Independence
By Jismy Joseph
Logical Data Independence
By Jismy Joseph
Physical & Logical
Data Independence
By Jismy Joseph
Structure of a DBMS
By Jismy Joseph
DBMS Structure
parser & query optimizer
Responsible for receiving query language statements and changing to a
form the DBMS can understand.
Transaction manager
The transaction manager maintains tables of authorization concurrency.
Recovery Manager
Ensures that the database remains in a consistent state in the presence
of failures. Responsible for transaction commit and abort.
Buffer Manager
Responsible for the transfer of data between main memory and
secondary storage.
Disk Space Manager
The lowest layer of the DBMS software deals with management of space
on disk, where data is stored. Higher layers allocate, deallocate, read
and write pages through this layer, called disk space manager.
By Jismy Joseph
DBMS Structure
Lock Manager
Keep track of request for locks and grants locks
on database objects when they become
available.
By Jismy Joseph
Overview of
Database Design
By Jismy Joseph
Entities, Attributes and Entity Sets
Entity
An entity is an object in the real world that is
distinguishable from other objects. For example a person
or a book.
Entity Set
A collection of similar entities are called entity set. For eg.
all employees of a bank.
Attribute
- An entity is described using a set of attribute.
- All entities in a given entity set have the same attributes.
- For eg. The attributes of the Employees entity set are
name, social security number etc.
By Jismy Joseph
Domain
Set of allowable values for one or more attributes.
Degree of a relation
The number of attributes the relation has.
Cardinality
Total number of records/tuples are knowns as
cardinality
By Jismy Joseph
Key, Primary Key, Candidate Key
Key
A key is a minimal set of attributes
whose values uniquely identify an
entity in the set.
By Jismy Joseph
Candidate key
The candidate key is also used to identify a particular
record. We can use either one attribute as a candidate
key or the combination of one or more attributes as
the candidate key. The subset of candidate key is not
again a candidate key. For eg. We can set studentId
attribute as candidate key or the combination of
StudentName and HouseNo attributes as the
candidate key, but we can’t use the combination of
StudentId, StudentName, & HouseNo attribute as the
Candidate key because the subsets ((StudentName,
HouseNo) , (StudentId)) of the above combination
(StudentId, StudentName, & HouseNo) can be used as
a candidate key.
By Jismy Joseph
primary key
candidate key selected to identify
tuples uniquely within relation.
Alternate Key
The key which is not used as a
primary key.
By Jismy Joseph
Relationships and relationship sets
A relationship is an association among two or
more entities. For eg
By Jismy Joseph
Relationships and Relationship sets
• A relationship can also have descriptive
attributes. Descriptive attributes are used to
record information about the relationship,
rather than about any one of the participating
entities. for example, we may wish to record
that Arun works in the pharmacy department as
of January 1991. This information is captured
in the following figure by adding an attribute,
since, to Works_In.
By Jismy Joseph
Relationships and Relationship sets
By Jismy Joseph
Relationships and Relationship sets
An instance of a relationship set is a set of
relationships. Intuitively, an instance can be
thought of as a 'snapshot' of the relationship
set at some instant in time.
An instance of the Works_ln relationship set is
shown in the following figure where Each
Employees entity is denoted by its ssn, and
each Departments entity is denoted by its did,
for simplicity. The since value is shown beside
each relationship.
By Jismy Joseph
Relationships and Relationship sets
51
56
60
By Jismy Joseph
Relationships and Relationship sets
suppose that each department has offices
in several locations and we want to record the
locations at which each employee works. This
relationship is ternary because we must record
an association between an employee, a
department, and a location. For Eg.
By Jismy Joseph
By Jismy Joseph
The entity sets that participate in a relationship set need not be
distinct; sometimes a relationship might involve two entities in
the same entity set.
By Jismy Joseph
Additional Features of the ER Model
Key Constraints
Key constraints are restrictions on the contents of
the database or on database operations.
For eg. each department has at most one manager. It
implies that each Departments entity appears in at
most one manager relationship in any allowable
instance of Manages. This restriction is indicated in
the ER diagram of the following Figure by using an
arrow from Departments to Manages. Intuitively, the
arrow states that given a Departments entity, we can
uniquely determine the Manages relationship in
which it appears. By Jismy Joseph
By Jismy Joseph
An instance of the Manages Relationship set is :
By Jismy Joseph
Key Constraints for Ternary Relationships
By Jismy Joseph
Each employee works in at most one
department and at a single location. Note that
each department can be associated with
several employees and locations and each
location can be associated with several
departments and employees; however, each
employee is associated with a single
department and location.
By Jismy Joseph
Aggregation
Aggregation allows us to indicate that a relationship
set participates in another relationship set.
By Jismy Joseph
• The dashed box around Sponsors (and its
participating entity sets) used to denote
aggregation.
• There are really two distinct relationships,
Sponsors and Monitors, each possibly with
attributes of its own.
• the Monitors relationship has an attribute until
that records the date until when the employee is
appointed as the sponsorship monitor.
• The Sponsors relationship has an attribute since
that records the date when the sponsorship took
effect. By Jismy Joseph
Conceptual Design with the E-R Model
• Entity versus Attribute
• Entity versus Relationship
• Binary versus Ternary Relationships
• Aggregation versus Ternary Relationships
By Jismy Joseph
Entity versus Attribute
By Jismy Joseph
Binary versus Ternary Relationships
By Jismy Joseph
• According to this diagram, a project can be
sponsored by any number of departments
• A department can sponsor one or more
projects.
• Each sponsorship is monitored by one or more
employees.
If we don't need to record the until attribute of
Monitors, then we might reasonably use a
ternary relationship, say, Sponsors2, as shown in
the following diagram
By Jismy Joseph
By Jismy Joseph
Overview of Unified
Modeling Languages(UML)
The Unified Modeling Language (UML) is a general-purpose
modeling language in the field of software engineering, which is
designed to provide a standard way to visualize the design of a system.
Business Modeling: In this phase, the goal is to describe the business
processes involved in the software application being developed.
By Jismy Joseph
• System Modeling: The understanding of business
processes is used to identify the requirements for the
software application. One part of the requirements is the
database requirements.
• Conceptual Database Modeling: This step corresponds to
the creation of the ER design for the database. For this
purpose, UML provides many constructs that parallel the
ER constructs.
• Physical Database Modeling: UML also provides pictorial
representations for physical database design choices,
such as the creation of table spaces and indexes.
• Hardware System Modeling: UML diagrams can be used
to describe the hardware configuration used for the
application.
By Jismy Joseph
There are many kinds of diagrams in UML.
Use case diagrams describe the actions performed by
the system in response to user requests, and the
people involved in these actions. These diagrams
specify the external functionality that the system is
expected to support.
Activity diagrams shows the flow of actions in a
business process.
Statechart diagrams describe dynamic interactions
between system objects.
Class diagrams are similar to ER diagrams, Both entity
sets and relationship sets can be represented as
classes in UML. By Jismy Joseph