18csc303j Dbms Unit I
18csc303j Dbms Unit I
18csc303j Dbms Unit I
Management Systems
20/10/2022 1
Outline of the Presentation
S-1 SLO-1 :What is Database Management System
SLO-2 :Advantage of DBMS over File Processing System
S-2 SLO-1 :Introduction and applications of DBMS
SLO-2 :Purpose of database system
S-3 SLO-1 & SLO2 :Views of data
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands on sample exercise
S-6 SLO-1 & SLO-2 : Database system Architecture
S-7 SLO-1 & SLO-2 : Data Independence
S-8 SLO-1 & SLO-2 : The evolution of Data Models
S-9-10 SLO-1 & SLO-2 : Lab 2: SQL Data Manipulation Language Commands
S-11 SLO-1 & SLO-2 : Degrees of Data Abstraction
S-12 SLO-1 & SLO-2 : Database Users and DBA
S-13 SLO-1 & SLO-2 : Database Languages
S-14-15SLO-1 & SLO-2 : Lab 3: SQL Data Control Language Commands and Transaction control
commands to the sample exercises
20/10/2022 2
S-1 SLO-1 : What is Database Management System ?
Data : It is a RAW FACT ( It won’t give any meaning )
Ex: 10, RAM, etc.
Information : Which gives meaning for Data
Ex: id = 10 , name = ‘RAM’ Distance in miles = 200, etc.
Database : Collection of meaningful interrelated information
Ex: DB2,ORACLE, SQL Server, MySQL, etc.
Database Management System ( DBMS ) :
• Database Management Systems (DBMS) are software systems used to store, retrieve, and
run queries on data which is stored in a database.
• A DBMS serves as an interface between an end-user and a database, allowing users to
create, read, update, and delete data in the database.
• DBMS manage the data, the database engine, and the database schema, allowing for
data to be manipulated or extracted by users and other programs.
• This helps provide data security, data integrity, concurrency, and uniform data
administration procedures.
20/10/2022 3
S-1 SLO-2 : Advantage of DBMS over File Processing System
A File Processing / Management system is a DBMS that allows access to single files or tables at a time. In
a File System, data is directly stored in set of files.
It contains flat files that have no relation to other files (when only one table is stored in single file, then this
file is known as flat file).
Data redundancy
Data inconsistency
Data Isolation
Data Security
20/10/2022 4
S-1 SLO-2 : Advantage of DBMS over File Processing System
Data Concurrency
Data Security
Data Privacy
Data Recovery
Flexible
20/10/2022 5
S-2 SLO-1 :Introduction and applications of DBMS
20/10/2022 7
S-2 SLO-1 :Introduction and applications of DBMS
Applications of DBMS
Domain Usage of DBMS
Managing customer information, account activities, payments,
Banking
deposits, loans, etc.
Maintain and Manage the Passenger Manifesto, reservations and
Transportation
schedule information.
Universities Student information, course registrations, colleges and grades.
It helps to keep call records, monthly bills, maintaining balances,
Telecommunication
etc.
For storing information about stock, sales, and purchases of
Finance
financial instruments like stocks and bonds.
Sales To store customer details , product details & sales information.
It is used for the management of supply chain and for tracking
Manufacturing
production of items. Inventories status in warehouses.
Social Media Manage the user accounts, Security, Data access
20/10/2022 8
S-2 SLO-2 :Purpose of database system
Purpose of DBMS:
The purpose of DBMS is to transform the following −
20/10/2022 9
S-2 SLO-2 :Purpose of database system
DATA
Purpose of DBMS:
The diagram given explains the process Information
as to how the transformation of data to
information to knowledge to action
happens respectively in the DBMS
knowledge
Action
( Processing)
20/10/2022 10
S-3 SLO-1 & SLO2 :Views of data
Data Abstraction
Data Abstraction is a process of hiding unwanted or irrelevant
details from the end user.
Data abstraction has different views and support in attaining data
independence which is used to enhance the security of data.
The database systems consist of complicated data structures and
relations.
20/10/2022 11
S-3 SLO-1 & SLO2 :Views of data
Levels of Abstraction
Logical level: describes data stored in database, and the relationships among
the data.
type student = record
student_reg_number : integer;
student_name : string;
student_degree : string;
customer_mobile : integer;
student_email : string
end;
View level: application programs hide details of data types. Views can also hide
information (such as an student’s mobile number /email) for security purposes.
20/10/2022 12
S-3 SLO-1 & SLO2 :Views of data
View of Data
View Level
Logical level
Physical
Level
20/10/2022 13
S-3 SLO-1 & SLO2 :Views of data
20/10/2022 14
S-3 SLO-1 & SLO2 :Views of data
20/10/2022 15
S-3 SLO-1 & SLO2 :Views of data
Data Models
• Data models is , a collection of tools for describing Data and its
relationships, Semantics and Constraints
• There are different types of data models are available in DBMS
• 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
20/10/2022 16
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands
on sample exercise
Structured Query Language ( SQL)
SQL became a standard of the American National Standards Institute (ANSI) in 1986, and
of the International Organization for Standardization (ISO) in 1987
Common language for all Databases
Fourth generation Language
Non procedural Language
Commands like an normal English statements
SQL is not a case sensitive language
All SQL statements should ended with terminator , the default terminator is semi-colon (;)
Based on the operation SQL divided into three categories
• DDL ( Data Definition Language)
• DML ( Data Manipulation Language)
• DCL ( Data Control Language)
20/10/2022 17
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands
on sample exercise
VARCHAR2
NUMBER
DATE
RAW
LONG
CLOB
BLOB , etc.,
20/10/2022 18
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands
on sample exercise
Data Definition Language (DDL)
DDL relates only with base tables structure and it is no where relates with the information stored in
the table.
Note : All the DDL command statements are AUTO COMMIT Statements
• CREATE
• ALTER
• DROP
• TRUNCATE
20/10/2022 19
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands
on sample exercise
CREATE COMMAND
Used to create a new object / schema with a defined structure
Syntax : CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
Example :
CREATE TABLE EMP
(EMPNO NUMBER(4) NOT NULL, ENAME VARCHAR2(10), JOB VARCHAR2(9),
MGR NUMBER(4), HIREDATE DATE, SAL NUMBER(7, 2), COMM NUMBER(7, 2),
DEPTNO NUMBER(2));
20/10/2022 20
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands
on sample exercise
ALTER COMMAND
20/10/2022 21
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands
on sample exercise
ALTER COMMAND
SYNTAX
20/10/2022 22
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands
on sample exercise
ALTER COMMAND
Example :
20/10/2022 23
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands
on sample exercise
DROP COMMAND
It is used to remove the base table with records (information) from
database permanently.
Syntax:
Example:
20/10/2022 24
S 4-5 SLO-1 & SLO-2 : Lab 1: SQL Data Definition Language Commands
on sample exercise
TRUNCATE COMMAND
Truncate command used to delete the records (information) from the
base table permanently and keeps the structure of the base table alone
Syntax:
Example:
20/10/2022 25
S-6 SLO-1 & SLO-2 : DATABASE SYSTEM ARCHITECTURE
There are four types users
accessing / managing the database
Naïve Users
Application Programmers
Sophisticated Users
Database Administrators
The database system is divided into
three components:
Query Processor
Storage Manager
Disk Storage.
20/10/2022 26
S-6 SLO-1 & SLO-2 : DATABASE SYSTEM ARCHITECTURE
Query Processor :
It interprets the requests (queries) from user(s) via an application
program /interface into instructions.
It also executes the user request which is received from the DML
compiler.
Query Processor contains the following components
Name of the Component Purpose of the component
DML Compiler It processes the DML statements into low level
instruction
DDL Interpreter It processes the DDL statements into a set of table
containing meta data
Embedded DML Pre-compiler It processes DML statements embedded in an application
program into procedural calls.
Query Optimizer It executes the instruction generated by DML Compiler.
20/10/2022 27
S-6 SLO-1 & SLO-2 : DATABASE SYSTEM ARCHITECTURE
Storage Manager :
It is an interface between the information stored in the database an
and the requests ( queries )
20/10/2022 28
S-6 SLO-1 & SLO-2 : DATABASE SYSTEM ARCHITECTURE
Storage Manager contains the following components
Components Purpose of the Components
Authorization It ensures role-based access control, i.e,. checks whether the particular
Manager person is privileged to perform the requested operation or not.
Integrity Manager It checks the integrity constraints when the database is modified.
Transaction Manager It controls concurrent access by performing the operations in a scheduled
way that it receives the transaction. Thus, it ensures that the database
remains in the consistent state before and after the execution of a
transaction.
File Manager It manages the file space and the data structure used to represent
information in the database.
Buffer Manager It is responsible for cache memory and the transfer of data between the
secondary storage and main memory.
20/10/2022 29
S-6 SLO-1 & SLO-2 : DATABASE SYSTEM ARCHITECTURE
Disk Storage
Used to store all the information
It contains the following components
20/10/2022 30
S-7 SLO-1 & SLO-2 : Data Independence
Data Independence is an important property of DBMS and also an advantage.
20/10/2022 31
S-7 SLO-1 & SLO-2 : Data Independence
20/10/2022 32
S-7 SLO-1 & SLO-2 : Data Independence
20/10/2022 33
S-7 SLO-1 & SLO-2 : Data Independence
It is defined as to make the changes in the structure of the logical level / view
level of DBMS without affecting the physical / low level.
20/10/2022 34
S-7 SLO-1 & SLO-2 : Data Independence
Difference between physical data independence and logical data independence
20/10/2022 35
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Hierarchical
Network
Entity relationship
Relational
Object oriented
20/10/2022 36
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Hierarchical Model
The first and fore most model of the DBMS.
This model organizes the data in the hierarchical tree structure.
This model is easy to understand with real time examples site map of a website
CLOTHES
MEN WOMEN
20/10/2022 37
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Features of a Hierarchical Model
One-to-many relationship:
Parent-Child Relationship
Deletion Problem:
Pointers
Complexity
Parent mode deleted automatically child node will be deleted
20/10/2022 38
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Network Model
Network model is an extension of hierarchical model.
This model was recommended as the best before relationship model.
Same like hierarchical model, the only difference between these two models are a
record can have more than one parent
For Example consider the following diagram a student entity has more than one
parent
COLLEGE
DEPARTMENT LIBRARY
STUDENT
20/10/2022 39
S-8 SLO-1 & SLO-2 : The evolution of Data Models
More paths
20/10/2022 40
S-8 SLO-1 & SLO-2 : The evolution of Data Models
1. Entities
2. Attributes
3. Relationships
20/10/2022 41
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Example for ER Diagram ( Faculty and Department entity set)
Dept_ID
Faculty_Id Faculty_Name
Works
Faculty Department
for
Phone_ No
Salary Dept_Location
Dept_Name
Date_of_ Birth
20/10/2022 42
S-8 SLO-1 & SLO-2 : The evolution of Data Models
20/10/2022 43
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Features of ER Model
Graphical representation
Visualization
Good Database design (Widely used)
Advantages of ER Model
Very Simple
Better communication
Easy to convert to any model
Disadvantage of ER Model
No industry standard
Hidden information
20/10/2022 44
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Relational Model
Widely used model
Data are represented as row-wise and column-wise ( 2 Dimensional Array)
Example : EMP (Employee) Table
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
20/10/2022 45
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Relational Model
Each row is known as RECORD or TUPLE
Table – EMP
20/10/2022 46
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Attributes
Scalable
Structured format
Isolation
20/10/2022 47
S-8 SLO-1 & SLO-2 : The evolution of Data Models
Object Oriented Model
The real- time problems are easily represented through
object-oriented data model which is an OBJECT.
In this Model, the data and its relationship present in the single structure
Complex data like images, audio, videos can be stored easily
Objects connected through links using common attribute(s)
Example : Three Objects Faculty, Department and Campus linked using common attribute
FACULTY
DEPARTMENT CAMPUS
ATTRIBUTES
Faculty_ID ATTRIBUTES ATTRIBUTES
Faculty_Name Dept_ID Campus_ID
Faculty_Designation Dept_Name Campus_Name
Faculty _Sal Dept_Location Campus_Location
Faculty_DOB Campus_ID
Faculty_MobileNo Methods
Methods New Campus Creation
Dept_ID Department Change Location Change
Methods Campus Change
Teaching_Subjects
Designation_Change
20/10/2022 48
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
Consider EMP table for DML operations
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPT
NO
7369 SMITH CLERK 7902 17-DEC-80 800 - 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 - 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 - 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 - 10
7788 SCOTT ANALYST 7566 09-DEC-82 3000 - 20
7839 KING PRESIDENT - 17-NOV-81 5000 - 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 12-JAN-83 1100 - 20
7900 JAMES CLERK 7698 03-DEC-81 950 - 30
7902 FORD ANALYST 7566 03-DEC-81 3000 - 20
7934 MILLER CLERK 7782 23-JAN-82 1300 - 10
20/10/2022 49
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
DML Commands are relates only with base table information ( value in an
attribute)
There are four commands in DML:
1. INSERT
2. UPDATE
3. DELETE
4. SELECT
20/10/2022 50
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
INSERT COMMAND
It relates only with new records.
Must follow the order of the column specified in the query statement
20/10/2022 51
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
INSERT COMMAND
Syntax:
20/10/2022 52
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
INSERT COMMAND
INSERT INTO EMP VALUES (7369, 'SMITH', 'CLERK', 7902, '17-12-1980‘, 800, NULL, 20);
(OR)
INSERT INTO EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO)
VALUES (7369, 'SMITH', 'CLERK', 7902, '17-12-1980', 800, NULL, 20);
The input value will be store in the appropriate field using bind
variable ( :OLD and :NEW)
20/10/2022 54
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
Update command
It works with only existing records
It works only column wise
It is used to modify the column values ( increase / decrease / change)
Syntax
UPDATE <table_name> set <field_name> = value [ where <condition>];
Note : Update command without where condition will update all the records.
Update command with where condition will update the records which are satisfy the
condition
Example 1:
UPDATE emp set comm = 2000 ; ( Update all the records in EMP table )
Example 2 :
Update emp set comm = 1000 where empno = 7369;
(Update the records having the empno as 7369)
20/10/2022 55
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
Delete command
It works only with existing records
It works only with row wise
It not possible to delete a single column in a row
Syntax
DELETE from <table_name> [ where <condition>];
Note : Delete command with out where condition will delete all the records in the table.
Delete command with where condition will delete the selected records which are
satisfy the condition.
Example 1: DELETE from emp; ( All records will be deleted from emp )
Example 2: DELETE from emp where empno = 7369;
( Those records holding the value in the field empno as 7369 will be deleted )
20/10/2022 56
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
SELECT COMMAND
Works with existing records
20/10/2022 57
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
SELECT COMMAND
Syntax
SELECT column_list FROM table-name
[WHERE Clause]
[GROUP BY clause]
[HAVING clause]
[ORDER BY clause];
NOTE : To retrieve all the column from the table ‘ * ’ symbol can be
used instead of specifying the column_list.
20/10/2022 58
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
SELECT COMMAND
Example 1: To retrieve all the columns and rows from emp table
SELECT * from emp; ( ‘*’ stands from all columns and rows )
Example 3: To retrieve the records from emp table which record holds the salary value greater
than 1000;
SELECT * from emp WHERE sal> 1000;
Example 4: To retrieve the columns empno and ename from emp table which records holds the
value as CLERK in job column.
SELECT empno, ename from emp WHERE job = ‘CLERK’
20/10/2022 59
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
SELECT COMMAND
Select command with order by clause
Example 5 : To retrieve the records from emp table in ascending order
using empno
SELECT * from emp order by empno asc;
(OR)
SELECT * from emp order by empno;
Example 6: To retrieve the records from emp table in ascending order
using job and empno
SELECT * from emp order by job,empno asc;
(OR)
SELECT * from emp order by job,empno;
NOTE : Ascending order is default condition, no need to specify
20/10/2022 60
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
SELECT COMMAND
Select command with order by clause
Example 7 : To retrieve the records from emp table in descending order using empno.
SELECT * from emp order by empno desc;
Example 8: To retrieve the records from emp table in descending order using job and
empno
SELECT * from emp order by job desc,empno desc;
Example 8: To retrieve the records from emp table in ascending order using job and
descending order empno
SELECT * from emp order by job asc,empno desc;
20/10/2022 61
S-9-10 SLO-1 & SLO-2 :
Lab 2: SQL Data Manipulation Language Commands
SELECT COMMAND
Select command with group by clause
Example 9: To retrieve the different jobs from emp table
SELECT job from emp group by job;
Example 10: To retrieve the different jobs and its average salary from emp table
SELECT job, avg(sal) from emp group by job;
20/10/2022 62
S-11 SLO-1 & SLO-2 : Degrees of Data Abstraction
Reference : https://databasemanagement.fandom.com/wiki/Degrees_of_Abstraction
20/10/2022 63
S-11 SLO-1 & SLO-2 : Degrees of Data Abstraction
The External Model is the end users' view of the data. The end users view of data
usually applies to their specific business needs and those of their organizational
unit.
The Conceptual Model is the database as seen by the specific DBMS. What sets
the internal model apart from the external and conceptual is its reliance on its
software platform.
The goal in designing the internal model is to achieve logical independence, where
the
internal model can be changed without affecting conceptual model.
Reference : https://databasemanagement.fandom.com/wiki/Degrees_of_Abstraction
20/10/2022 64
S-11 SLO-1 & SLO-2 : Degrees of Data Abstraction
The Physical Model is the final and lowest level of abstraction. This is the model
which describe such implementation level design as how the data is stored on
media and what media to use. This level of abstraction is reliant on software and
hardware.
Note:
If the rules established by the ANSI/SPARC are followed, the database is
easily scalable and upgradeable.
A common need is for the ease of upgradability in the physical model.
As technology improves and as the database grows and needs more
processing power and space it is important to be able to upgrade the
hardware without worrying about needing to redesign parts or the entire
database.
Reference : https://databasemanagement.fandom.com/wiki/Degrees_of_Abstraction
20/10/2022 65
S-12 SLO-1 & SLO-2 : Database Users and DBA
Database Users
Naive Users
Application Programmers
Sophisticated Users
Native Users
Specialized Users
Stand-alone Users
20/10/2022 66
S-12 SLO-1 & SLO-2 : Database Users and DBA
Naive Users
Those who don’t have any knowledge about DBMS
Use DBMS applications frequently
Mostly using the internet browser as an interface to access the database
They don’t have any privileges to modify the database, simply use the application
Example : Railway booking users, Clerks in bank accessing database
Application Programmers
Users who develop DBMS applications.
They are backend programmers
Programs can be written in any programming languages like C++, JAVA, Python, PHP
20/10/2022 67
S-12 SLO-1 & SLO-2 : Database Users and DBA
Sophisticated Users
Having knowledge about database and DBMS
They can create their own applications based on requirements
They don’t write codes in any programming languages, but able to manage using queries
Example : Business Analyst, Researchers
Native Users
These are the users, who use the existing database applications
They don’t write any codes or queries
Example: Library Management Systems, Inventory Control Systems
20/10/2022 68
S-12 SLO-1 & SLO-2 : Database Users and DBA
Specialized Users
These are also sophisticated users, but they write special database application
programs.
They are the developers who develop the complex programs to the requirement.
Stand-alone Users
These users will have a stand-alone database for their personal use.
These kinds of the database will have readymade database packages
which will have menus and graphical interfaces.
20/10/2022 69
S-12 SLO-1 & SLO-2 : Database Users and DBA
20/10/2022 70
S-13 SLO-1 & SLO-2 : Database Languages
20/10/2022 71
S-13 SLO-1 & SLO-2 : Database Languages
Can specify the storage structure and access methods used by the database
system by a set of statements in a special type of DDL called a data storage and
definition language.
20/10/2022 72
S-13 SLO-1 & SLO-2 : Database Languages
Data Definition Language (DDL)
Different types of constraints
Domain Constraints
• Data types , Not Null, Check ,Unique, Primary key
Referential Integrity constraints
• Foreign key
Assertions
• Any condition that the database must satisfy.
• Domain and Referential Integrity constraints are special forms of assertion.
Authorization
• User Authorization
• Read Authorization
• Insert Authorization
• Update Authorization
• Delete Authorization
Note : The output of the DDL will be stored in Data Dictionary which contains all the details
about the data, like meta-data
20/10/2022 73
S-13 SLO-1 & SLO-2 : Database Languages
Data Manipulation Language
Enables users to access or manipulate data as organized by the
appropriate data model.
The followings are the different types of access
• Procedural DMLs require a user to specify what data are needed and how to
get those data.
Used to give / get back / control the privileges of an object by the owner
on <OBJECT_NAME> to <USER_NAME>;
REVOKE : To get back all the privileges from the user who has been granted
20/10/2022 75
S-14-15SLO-1 & SLO-2 : Lab 3: SQL Data Control Language
commands and Transaction control commands to the sample
exercises
20/10/2022 76