You are on page 1of 58

Database Management System

(DBMS)
CAP200
1. Basic Concepts : Purpose of database systems, Components of DBMS,
DBMS Architecture, Data Independence, Different Data Models,
Various types of constraints
2. Structure of Relational Databases : Relational Databases, Relational
Algebra, Views, DDL statements in SQL, DML statements in SQL, JOINS
3. Database Design : Design guidelines, Relational database design,
Pitfalls in Relational Database Design, Second Normal Form, Third
Normal Form, Forth Normal Form, Fifth Normal Form, First Normal
Form, Types of dependencies
4. Transaction Processing : Transaction concept, Desirable properties of
transactions, Schedules and Recoverability, Serializability of schedules
5. Concurrency Control and Recovery : Lock-Based Protocols, Deadlock
Handling, Multiple Granularity, Timestamp-Based Protocols, Validation-
Based Protocols, Failure Classification, Buffer Management, Failure
with Loss of Nonvolatile Storage, Log based recovery, Shadow paging
6. Distributed Databases : Distributed Databases, Client /Server
Databases, Data Fragmentation, Replication and Allocation Techniques,
SemiJoin, Homogeneous and Heterogeneous Databases, Distributed
Data Storage, Distributed Transactions, Cloud-Based Databases
Text Books:
• DATABASE SYSTEMS CONCEPTS by
ABRAHAM SILBERSCHATZ, HENRY F. KORTH,
S. SUDARSHAN, MCGRAW HILL EDUCATION

References:
• 1. AN INTRODUCTION TO DATABASE DESIGN
by
C. J. DATE, S. SWAMYNATHAN, A. KANNAN,
PEARSON
• 2. FUNDAMENTALS OF DATABASE SYSTEMS by
ELMASRI AND NAVATHE, PEARSON
• CA’S THREE and Two best will be picked up
• Mid term
• End term
Paradigm Shift from File System to DBMS
File System manages data using files in hard disk. Users are
allowed to create, delete, and update the files according
to their requirement.

Issues with this system:


• Redundancy of data: Data is said to be redundant if same
data is copied at many places. If a student wants to
change Phone number, he has to get it updated at
various sections. Similarly, old records must be deleted
from all sections representing that student.
• Inconsistency of Data: Data is said to be inconsistent if
multiple copies of same data does not match with
each other. If Phone number is different in Accounts
Section and Academics Section, it will be inconsistent.
Inconsistency may be because of typing errors or not
updating all copies of same data.
• Difficult Data Access: A user should know the exact
location of file to access data, so the process is very
cumbersome and tedious. If user wants to search student
hostel allotment number of a student from 10000 unsorted
students’ records, how difficult it can be.
• Unauthorized Access: File System may lead to
unauthorized access to data. If a student gets access to file
having his marks, he can change it in unauthorized way.
• No Concurrent Access: The access of same data by
multiple users at same time is known as concurrency. File
system does not allow concurrency as data can be accessed
by only one user at a time.
• No Backup and Recovery: File system does not incorporate
any backup and recovery of data if a file is lost or
corrupted.
BASIC Terminology
The Data is collection of raw facts and figures.
The word raw means that the facts have not yet
been processed to get their exact meaning.
The process of sorting or calculating data is
called Data Processing.
Information is a processed, organized data
presented in a given context and is useful to
humans.
What is Database ?

The database is a collection of inter-related data which is used to retrieve, insert


and delete the data efficiently.
It is also used to organize the data in the form of a table, schema, views, and
reports, etc.
For example: The college Database organizes the data about the admin,
staff,
students and faculty etc.
Using the database, you can easily retrieve, insert, and delete the
information.
Database Management System

• Database management system is a software which is used


to manage the database.
• For example: MySQL, Microsoft Access, Oracle, dBASE,
FoxPro, SQLite, IBM DB2.
etc are a very popular commercial database which is used in
different applications.

• DBMS provides an interface to perform various operations


like database creation, storing data in it, updating data,
creating a table in the database and a lot more.
• It provides protection and security to the database. In the
case of multiple users, it also maintains data consistency.
Purpose of Database System
• In the early days, database applications were built 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 — Data isolation is a property that determines
when and how changes made by one operation become visible
to other concurrent users and systems.
- Integrity problems
• Integrity constraints (e.g. account balance > 0) become part of
program code
• Hard to add new constraints or change existing ones
• Drawbacks of using file systems (cont.)
– Atomicity of updates
• Failures may leave database in an inconsistent state with
partial updates carried out
• E.g. 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
– E.g. two people reading a balance and updating it at the same
time
– Security problems
• Database systems offer solutions to all the above
problems
DBMS COMPONENTS
Storage engine
The storage engine is the core component of the
DBMS that interacts with the file system at an
OS level to store data. All SQL queries which
interact with the underlying data go through the
storage engine.
Query language
A database access language is required for
interacting with a database, from creating
databases to simply inserting or retrieving data.
A proper DBMS must support one or multiple
query languages and language dialects.
Structured query language (SQL) and MongoDB
Query Language (MQL) are two query languages
that are used to interact with the databases.
In many query languages, the query language functionality
can be further categorized according to specific tasks:
• Data Definition Language (DDL). This consists of
commands that can be used to define database schemas or
modify the structure of database objects.
• Data Manipulation Language (DML). Commands that
directly deal with the data in the database. All CRUD
operations come under DML.
• Data Control Language (DCL). This deals with the
permissions and other access controls of the database.
• Transaction Control Language (TCL). Command which deals
with internal database transactions.
Query processor
• This is the intermediary between the user
queries and the database. The query processor
interprets the queries of users and makes them
actionable commands that can be understood
by the database to perform the appropriate
functionality.

Optimization engine
it can provide a powerful toolset to gain the
best performance out of the database
Log manager
• This component will keep all the logs of the
DBMS. These logs will consist of user logins
and activity, database functions, backups and
restore functions, etc. The log manager
ensures all these logs are properly recorded
and easily accessible.
Reporting & monitoring tools
• Reporting and monitoring tools are another
standard component that comes with a DBMS.
Reporting tools will enable users to generate
reports while monitoring tools enable
monitoring the databases for resource
consumption, user activity, etc.
Exampl
e
RDBMS
• Users: Users may be of any kind such as DB
administrator, System developer, or database
users.
• Database application: Database application
may be Departmental, Personal, organization's
and / or Internal.
• DBMS: Software that allows users to create
and manipulate database access,
• Database: Collection of logical data as a single
unit.
DBMS Architecture
There are three types of DBMS Architecture :
• 1-Tier Architecture
• 2-Tier Architecture
• 3-Tier Architecture
1-Tier Architecture
1 Tier Architecture in DBMS is the simplest architecture of Database
in which the client, server, and Database all reside on the same
machine. A simple one tier architecture example would be anytime
you install a Database in your system and access it to practice SQL
queries.
2-Tier Architecture
A 2 Tier Architecture in DBMS is a Database architecture where the
presentation layer runs on a client (PC, Mobile, Tablet, etc.), and
data is stored on a server called the second tier. Two tier
architecture provides added security to the DBMS as it is not
exposed to the end- user directly. It also provides direct and faster
communication.
Example : A Contact Management System created using MS- Access.
3-Tier Architecture
3 Tier Architecture in DBMS is the most popular client server
architecture in DBMS in which the development and maintenance of
functional processes, logic, data access, data storage, and user
interface is done independently as separate modules. Three Tier
architecture contains a presentation layer, an application layer, and a
database server.

3-Tier database Architecture design is an extension of the 2-tier


client-server architecture. A 3-tier architecture has the following
layers:
• Presentation layer (your PC, Tablet, Mobile, etc.)
• Application layer (server)
• Database Server
The Application layer resides between the user and the DBMS, which is responsible for
communicating the user’s request to the DBMS system and send the response from the
DBMS to the user. The application layer(business logic layer) also processes functional
logic, constraint, and rules before passing data to the user or down to the DBMS.

The goal of Three Tier client-server architecture is:


• To separate the user applications and physical database
• To support DBMS characteristics
• Program-data independence
• Supporting multiple views of the data
Example:
Any large website on the internet, Myntra
Data Independence
Data independence can be explained using the
three-schema architecture.
Data independence refers characteristic of being
able to modify the schema at one level of the
database system without altering the schema at the
next higher level.
There are two types of data independence:

1. Logical Data Independence


• Logical data independence refers characteristic of
being able to change the conceptual schema
without having to change the external schema.
• Logical data independence is used to separate the
external level from the conceptual view.
• If we do any changes in the conceptual view of
the data, then the user view of the data would
not be affected.
• Logical data independence occurs at the user
interface level.
The conceptual schema describes the Database structure of the
whole database for the community of users.
This schema hides information about the physical storage
structures and focuses on describing data types,
relationships, etc. entities,
External/
Physical Data Independence
• Physical data independence can be defined as the
capacity to change the internal schema without
having to change the conceptual schema.
• If we do any changes in the storage size of the
database system server, then the Conceptual
structure of the database will not be affected.
• Physical data independence is used to separate
conceptual levels from the internal levels.
• Physical data independence occurs at the logical
interface level.
• Physical Data Independence
• Physical data independence can be defined as the
capacity to change the internal schema without
having to change the conceptual schema.
• If we do any changes in the storage size of
the database system server, then the
Conceptual structure of the database will not
be affected.
• Physical data independence is used to separate
conceptual levels from the internal levels.
• Physical data independence occurs at the
logical interface level.
Data Models
Hierarchical Model
Hierarchical Model was the first DBMS model. This
model organises 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. This
model easily represents some of the real-world
relationships like food recipes, sitemap of a website
etc.
Example: We can represent the relationship between the shoes
present on a shopping website in the following way:
Features of a Hierarchical Model
• One-to-many relationship: The data here is organised in a tree- like structure
where the one-to-many relationship is between the datatypes. Also, there can
be only one path from parent to any node. Example: In the above example, if
we want to go to the node sneakers we only have one path to reach there i.e
through men's shoes 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.

• 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. Example: In the above
example the 'shoes' node points to the two other nodes 'women shoes' node
and 'men's shoes' node.
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.
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.
Features of a Network Model
• Ability to Merge more Relationships: In this model,
as there are more relationships so data is more
related. This model has the ability to manage one-
to- one relationships as well as many-to-many
relationships.
• Many paths: As there are more relationships so
there can be more than one path to the same
record. This makes data access fast and simple.
.
Given below is the pictorial representation of the network model in
DBMS
Object-Oriented Data Model

In this model, two are more objects are connected


through links. We use this link to relate one object to
other objects. This can be understood by the example
given below.
Example
 

 The objects Circle, Rectangle and Triangle inherit from the object Shape

 Circle has the attributes Center and Radius.


 Rectangle has the attributes Length and Breath
 Triangle has the attributes Base and Height.
Entity-Relationship Model
 In this model, we represent the real-world
problem in the pictorial form to make it easy to
understand.
 It also develops a very simple and easy to design
view of data.
 In ER modeling, the database structure is
portrayed as a diagram called an entity-
relationship diagram.
IMP Terminology
 Entity : An Entity may be an object with a physical existence – a particular
person, car, house, or employee.

Attribute(s): 
The attribute is used to describe the property of an entity. Eclipse is used to
represent an attribute.
For example, id, age, contact number, name, etc. can be attributes of a student.
 
1. Key Attribute – 

The attribute which uniquely identifies each entity . It represents a primary key. The
key attribute is represented by an ellipse with the text underlined.

2. Composite Attribute – 
An attribute that composed of many other attributes is known as a composite
attribute. The composite attribute is represented by an ellipse, and those ellipses are
connected with an ellipse.
3. Multivalued Attribute – 
An attribute can have more than one value. These attributes are known as a multivalued
attribute. The double oval is used to represent multivalued attribute.

For example, a student can have more than one phone number.
d. Derived Attribute
An attribute that can be derived from other attribute is known as a derived
attribute. It can be represented by a dashed ellipse.

For example, A person's age changes over time and can be derived from
another attribute like Date of birth.
Relationship

A relationship is used to describe the relation between entities. Diamond or rhombus


is used to represent the relationship.

Different types of cardinal relationships are:


• One-to-One Relationships
• One-to-Many Relationships
• Many to One Relationships
• Many-to-Many Relationships
a. One-to-One Relationship

For example, A female can marry to one male, and a male can
marry to one female.
b. One-to-many relationship

For example, Scientist can invent many inventions, but the invention is done by the
only specific scientist.

c. Many-to-one relationship

For example, Student enrolls for only one course, but a course can have many
students.
d. Many-to-many relationship

For example, Employee can assign by many projects and project can have many
employees.
Example:
Following are the main components and its
symbols in ER Diagrams:
• Rectangles: This Entity Relationship
Diagram symbol represents entity types.
• Ellipses : Symbol represent attributes.
• Diamonds: This symbol represents
relationship types.
• Lines: It links attributes to entity types and
entity types with other relationship types.
• Primary key: attributes are underlined.
• Double Ellipses: Represent multi-valued
attributes.
Features of ER Model
• Graphical for
Understanding: It is very easy Better
Representation
understand so it can be used by theand simple to
developers to
communicate with the stakeholders.
• ER Diagram: ER diagram is used as a visual tool for
representing the model.
• Database Design: This model helps the database
designers to build the database and is widely used
in database design.
Why Relational Model ?

 Relational Model was proposed by E.F. Codd to model data in the form of relations or
tables.

 After designing the conceptual model of Database using ER diagram, we need to


convert the conceptual model in the relational model which can be implemented
using any RDBMS languages like Oracle SQL, MySQL etc. So we will see what
Relational Model is.

What is Relational Model? 

Relational Model represents how data is stored in Relational Databases.  A relational


database stores data in the form of relations (tables).
Features of Relational Model

Tuple: 
 Each row in the relation is known as tuple.
 The above
1 relation contains 4 tuples,
RAM DELHI one of which9455123451
is shown as: 18

Attribute: Attributes are the properties that define a relation. e.g.; ROLL_NO, NAME

Degree: The number of attributes in the relation is known as degree of the relation.


The STUDENT relation defined above has degree 5.

Cardinality: The number of tuples in a relation is known as cardinality.


The STUDENT relation defined above has cardinality 4.
DBMS Integrity Constraints - javatpoint

You might also like