Introduction of DBMS
Introduction of DBMS
UNIT-IV
TRANSACTIONS AND CONCURRENCY MANAGEMENT: Transactions – Concurrent
Transactions - Locking Protocol - Serialisable Schedules - Locks Two Phase
Locking (2PL) - Deadlock and its Prevention - Optimistic Concurrency Control.
Database Recovery and Security: Database Recovery meaning - Kinds of failures -
Failure controlling methods - Database errors – Backup & Recovery Techniques -
Security & Integrity - Database Security - Authorization.
UNIT-V
• DISTRIBUTED AND CLIENT SERVER DATABASES : Need for Distributed
Database Systems - Structure of Distributed Database - Advantages and
Disadvantages of DDBMS - Advantages of Data Distribution -
Disadvantages of Data Distribution - Data Replication – Data
Fragmentation.
• Client Server Databases: Emergence of Client Server Architecture - Need
for Client Server Computing - Structure of Client Server Systems & its
advantages.
• ADVANCED TOPICS: Overview: Parallel Database - Multimedia Database -
Mobile Database – Web Database - Multidimensional Database. Data
Warehouse - OLTP v/s OLAP – No SQL Database.
Capture Data
Manipulate
Output / Results
Information
Data Processing System
Need of Information
• To gain knowledge about surrounding and
whatever is happening in the society and universe.
• To keep the system up-to-date we need to gather
information from various sources like news paper,
radio, magazine, television, internet etc.
• To know about the rules and regulation of society,
government and association etc.
• To arrive at a particular decision that helps in
forming and protecting system.
Data Hierarchy
• BIT- 0, 1.
• BYTE- 8 bit.
• FIELD- Group of character. BIT
• DATABASE- Collection of
RECORD FILE
related files.
DATABASE
Database Application/ Uses
• Banking
• University
• Airlines
• Railway Reservation/ Bus Reservation
• Sales
• Telecommunication
• Manufacturing
• Human Resources
Approaches to Data Management
• Two approaches used for data management
through computer
1. File Based System approach
2. Database Approach
1. File Processing System: A file system is a method for storing and
organizing computer files and the data they contain to make it easy
to find and access them. File systems may use a storage device such
as a hard disk or CD-ROM and involve maintaining the physical
location of the files.
Characteristics of File Base System
• It is a group of files storing data of an organization.
• Each file is independent from one another.
• Each file is called a flat file.
• Each file contained and processed information for one specific
function, such as accounting or inventory.
• Files are designed by using programs written in programming
languages such as COBOL, C, C++.
• Each file must have its own file management system.
Disadvantages of file system include:
• Separated and Isolated Data
• Duplication of data (Redundancy)
• Data Dependence & Inconsistency
• Difficulty in accessing data
• Concurrent access anomalies
• Security problem
• Integrity problems
• Atomicity Problem
• Data Inflexibility
• Incompatible file formats
• Data Security
• Transactional Problems
2. DBMS: A DBMS is a software that allows creation, definition and
manipulation of database, allowing users to store, process and analyse
data easily. DBMS provides us with an interface or a tool, to perform
various operations like creating database, storing data in it, updating
data, creating tables in the database and a lot more.
“Relational Database Management System" An RDBMS is a DBMS
designed specifically for relational databases. Therefore, RDBMSes
are a subset of DBMS.
Data Integrity
Data integrity means that the data is accurate and consistent in the database.
Data Integrity is very important as there are multiple databases in a DBMS.
All of these databases contain data that is visible to multiple users. So it is
necessary to ensure that the data is correct and consistent in all the
databases and for all the users.
Data Security
Data Security is vital concept in a database. Only authorised users should
be allowed to access the database and their identity should be
authenticated using a username and password. Unauthorised users should
not be allowed to access the database under any circumstances as it
violates the integrity constraints.
Privacy
The privacy rule in a database means only the authorized users can access
a database according to its privacy constraints. There are levels of
database access and a user can only view the data he is allowed to. For
example - In social networking sites, access constraints are different for
different accounts a user may want to access.
Backup and Recovery
Relational Database Management System automatically takes care of backup
and recovery. The users don't need to backup data periodically because this is
taken care of by the DBMS. Moreover, it also restores the database after a
crash or system failure to its previous condition.
Data Consistency
Data consistency is ensured in a database because there is no data redundancy.
All data appears consistently across the database and the data is same for all
the users viewing the database. Moreover, any changes made to the database
are immediately reflected to all the users and there is no data inconsistency
Data Administration
Data administration is the process by which data is monitored,
maintained and managed by a data administrator and/or an
organization. Data administration allows an organization to control its
data assets, as well as their processing and interactions with different
applications and business processes. Data administration ensures that
the entire life cycle of data use and processing is on par with the
enterprise’s objective
Disadvantage of RDBMS
➨Software is expensive.
➨Complex software refers to expensive hardware
and hence increases overall cost to avail the
RDBMS service.
➨It requires skilled human resources to implement.
➨Certain applications are slow in processing.
➨It is difficult to Backup and recover the lost data.
➨ Security Threats.
DBMS Architecture
The architecture explains database concepts, structure and
capabilities of a DBMS.
The logical architecture deals with the way data is stored and
presented to users, while the physical architecture is concerned
with the software components that makes up a DBMS.
Three Level Architecture of Database
Logical database
Architecture deals with
the way data is stored
and presented to users.
Physical Level
This is the lowest level in the three level architecture.
It is also known as the internal level. The physical
level describes how data is actually stored in the
database. In the lowest level, this data is stored in the
external hard drives in the form of bits and at a little
high level, it can be said that the data is stored in files
and folders. The physical level also discusses
compression and encryption techniques.
Conceptual Level
The conceptual level is at a higher level than the
physical level. It is also known as the logical level. It
describes how the database appears to the users
conceptually and the relationships between various
data tables. The conceptual level does not care for
how the data in the database is actually stored.
External Level
This is the highest level in the three level
architecture and closest to the user. It is also
known as the view level. The external level only
shows the relevant database content to the users in
the form of views and hides the rest of the data. So
different users can see the database as a different
view as per their individual requirements.
Physical Architecture
• Database systems are partitioned into modules for
different functions. Components of database
systems include:
– File manager - manages allocation of disk
space and data structures used to represent
information on disk.
– Database manager: The interface between low-
level data and application programs and queries.
– Query processor translates statements in a query
language into low-level instructions the database
manager understands. (May also attempt to find an
equivalent but more efficient form.)
– DML Precompiler converts DML statements
embedded in an application program to normal
procedure calls in a host language. The
Precompiler interacts with the query processor.
– DDL compiler converts DDL statements to a set
of tables containing metadata stored in a data
dictionary.
– Run-time processor – The run-time processor
handles retrieval or update operations
expressed against database.
– Query processor – The query processor
handles interactive queries expressed in data
manipulation language (DML) such as SQL. It
parses and analyses a query before generating
calls to the run-time
• In addition, several data structures are required for
physical system implementation:
Data definition
The DBMS provides functions to define the structure of the
data in the application. These include defining and modifying
the record structure, the type and size of fields and the
various constraints/conditions to be satisfied by the data in
each field.
Data Manipulation
Once the data structure is defined, data needs to be inserted, modified
or deleted. The functions which perform these operations are also
part of the DBMS. These functions can handle planned and
unplanned data manipulation needs. Planned queries are those which
form part of the application. Unplanned queries are ad-hoc queries
which are performed on a need basis.
Security
Security classifications are implemented that identify which user groups
are authorized to access specific data elements in the database and what
actions may be performed thereon. Computer operations are frequently
monitored to assure that these access controls are functioning in the
intended way.
Types of databases :
Databases can be classified according to the number
of users, location of DB, and the uses.
KEY is an attribute or set of attributes which helps you to identify a row(tuple) in a
relation(table). They allow you to find the relation between two tables. Keys help you
uniquely identify a row in a table by a combination of one or more columns in that
table. Key is also helpful for finding unique record or row from the table. Database key
is also helpful for finding unique record or row from the table.
Primary Key – A primary is a column or set of columns in a table that uniquely identifies
tuples (rows) in that table.
Super Key – A super key is a set of one of more columns (attributes) to uniquely identify
rows in a table.
Candidate Key – A super key with no redundant attribute is known as candidate key
Alternate Key – Out of all candidate keys, only one gets selected as primary key,
remaining keys are known as alternate or secondary keys.
Composite Key – A key that consists of more than one attribute to uniquely identify rows
(also known as records & tuples) in a table is called composite key.
Foreign Key – Foreign keys are the columns of a table that points to the primary key of
another table. They act as a cross-reference between tables.
student Sid(PK) Sname contact
1001 aa 99999
NOT NULL
DEFAULT
CHECK
Key Constraints
There must be at least one minimal subset of attributes in the
relation, which can identify a tuple uniquely. This minimal subset of
attributes is called key for that relation. If there are more than one
such minimal subsets, these are called candidate keys.
Key constraints force that −
•in a relation with a key attribute, no two tuples can have identical
values for key attributes.
•a key attribute can not have NULL values.
Key constraints are also referred to as Entity Constraints.
- Primary key constraint
- Unique key constraint
Example- Consider the following Student table
S001 Akshay 20
S001 Abhishek 21
S003 Shashank 20
S004 Rahul 20
Integrity constraints
It states that no primary key value can be Null. This because the
primary key is used to identify individual tuple in the relation.
Notation: σ p(r)
Where:
σ is used for selection prediction
r is used for relation
p is used as a propositional logic formula which may use connectors
like: AND OR and NOT. These relational can use as relational operators
like =, ≠, ≥, <, >, ≤.
For example: LOAN Relation
BRANCH_NAME LOAN_NO AMOUNT
Downtown L-17 1000
Redwood L-23 2000
Perryride L-15 1500
Downtown L-14 1500
Mianus L-13 500
Roundhill L-11 900
Perryride L-16 1300
Input:
σ BRANCH_NAME="perryride" (LOAN)
BRANCH_NAME LOAN_NO AMOUNT
Output:
Perryride L-15 1500
Perryride L-16 1300
2. Project Operation:
Input: ∏ CUSTOMER_NAME (BORROW) ∪ ∏ CUSTOMER_NAME (DEPOSITOR)
CUSTOMER_NAME
Output: Johnson
Smith
Hayes
Turner
Jones
Lindsay
Jackson
Curry
Williams
Mayes
4. Set Intersection:
Suppose there are two tuples R and S. The set intersection operation contains
all tuples that are in both R & S.
It is denoted by intersection ∩.
Notation: R ∩ S
Example: Using the above DEPOSITOR table and BORROW table
DEPOSITOR BORROW
CUSTOMER_NAME ACCOUNT_NO CUSTOMER_NAME LOAN_NO
Jones L-17 Output:
Johnson A-101
Smith A-121 Smith L-23
Mayes A-321 Hayes L-15 CUSTOMER_NAME
Jackson L-14
Turner A-176 Smith
Johnson A-273 Curry L-93
Jones A-472 Smith L-11 Jones
Lindsay A-284 Williams L-17
Input:
∏ CUSTOMER_NAME (BORROW) ∩ ∏ CUSTOMER_NAME (DEPOSITOR)
5. Set Difference:
Suppose there are two tuples R and S. The set intersection operation contains all
tuples that are in R but not in S.
It is denoted by intersection minus (-).
Notation: R - S
Example: Using the above DEPOSITOR table and BORROW table
∏ CUSTOMER_NAME (BORROW) - ∏ CUSTOMER_NAME (DEPOSITOR)
6. Cartesian product
The Cartesian product is used to combine each row in one table with each row in the
other table. It is also known as a cross product.
It is denoted by X (cross).
Notation: E X D
EMPLOYEE DEPARTMENT
EMP_ID EMP_NAME EMP_DEPT
DEPT_NO DEPT_NAME
1 Smith A
A Marketing
2 Harry C
B Sales
3 John B
C Legal
Input: EMPLOYEE X DEPARTMENT
Output: EMP_ID EMP_NAME EMP_DEPT DEPT_NO DEPT_NAME
1 Smith A A Marketing
1 Smith A B Sales
1 Smith A C Legal
2 Harry C A Marketing
2 Harry C B Sales
2 Harry C C Legal
3 John B A Marketing
3 John B B Sales
3 John B C Legal
7. Rename Operation:
The rename operation is used to rename the output
relation. It is denoted by rho (ρ).
Example: We can use the rename operator to rename
STUDENT relation to STUDENT1.
ρ(STUDENT1, STUDENT)
Entity Relationship (ER) Model
The ER or (Entity Relational Model) is a high-level
conceptual data model diagram. Entity-Relation model
is based on the notion of real-world entities and the
relationship between them.
Examples of Attributes
Employee – empname, emp_no, emp_sal etc.
Student – stu_id, student_name, course, etc.
Composite Attribute-If the attributes are composite, they are further divided into
many another simple attributes. That is, composite attributes are represented by
ellipses that are connected with an ellipse.
Single Valued Attributes- Single valued attributes are those attributes which can
take only one value for a given entity from an entity set.
Multi Valued Attributes- Multi valued attributes are those attributes which can
take more than one value for a given entity from an entity set.
Derived Attributes- Derived attributes are those attributes which can be
derived from other attribute.
Key Attributes- Key attributes are those attributes which can identify an
entity uniquely in an entity set.
In the above example roll_no is key attribute.
Relationship
A relationship is represented by diamond shape in ER diagram, it shows the
relationship among entities. There are four types of relationships:
1. One to One
2. One to Many
3. Many to One
4. Many to Many
1. One to One Relationship
When a single instance of an entity is associated with a single instance of another
entity then it is called one to one (1:1) relationship. For example, a person has only one
passport and a passport is given to one person.
2. One to Many Relationship
When a single instance of an entity is associated with more than one instances of another
entity then it is called one to many (1:N) relationship. For example – a customer can place
many orders but a order cannot be placed by many customers.
Or
In search just sql
1. Connect DB server :
connect
username: system/scott (name given at the time of instalation )
password: system (default)