0% found this document useful (0 votes)
12 views17 pages

DBMS Unit 1

The document provides an overview of Database Management Systems (DBMS), including their characteristics, advantages, and architecture. It discusses the differences between file systems and DBMS, the types of database users, and the importance of data independence. Additionally, it outlines the three-tier architecture of DBMS and its benefits and drawbacks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views17 pages

DBMS Unit 1

The document provides an overview of Database Management Systems (DBMS), including their characteristics, advantages, and architecture. It discusses the differences between file systems and DBMS, the types of database users, and the importance of data independence. Additionally, it outlines the three-tier architecture of DBMS and its benefits and drawbacks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Database Management System B.

Tech(CSE) II Year II Sem

UNIT I
Introduction: Database system, Characteristics (Database Vs File System), Database
Users(Actors on Scene, Workers behind the scene), Advantages of Database systems, Database
applications. Concepts of Schema, Instance and data independence; Three tier schema
architecture for data independence; Database system structure, environment, Centralized and
Client Server architecture for the database.
Basic SQL: Simple Database schema, data types, table definitions (create, alter), different DML
operations (insert, delete, update).

Data
The raw facts are called as data. The word “raw” indicates that they have not been processed.
Examples:
Ages of employees: 25; 29; 45; 23; 60; 51; 35 …
Names of employees: Ben; Anna: Mark; Kathy; Rose; Jack; Jane …
Information
The processed data is known as information.
Ex: Ages of Employees: Ben is 25 yrs old; Anna is 29 yrs old; Mark is 45 yrs old; Kathy is 35
yrs old; Rose is 60 yrs old; while Jack is 51 yrs old…
Knowledge
knowledge is the awareness or the conscious understanding of information or a concept
1. Knowledge refers to the practical use of information.
2. Knowledge necessarily involves a personal experience.
Example: Our employees Ben, Anna, and Kathy are still young and they are prospective leaders
of the firm.
DATA/INFORMATION PROCESSING:
The process of converting the data (raw facts) into meaningful information is called as
data/information processing.

File: The collection of data is called a file that is stored in the computer with a file name.
These files are managed by the File Based system.
File Based Systems
File is a collection of data which is stored in computer. Each file has a specific format.
The files are managed by File system.
A file system is a technique of arranging the files in a storage medium like a hard disk, pen drive,
DVD, etc. It helps you to organizes the data and allows easy retrieval of files when they are
required. It mostly consists of different types of files like mp3, mp4, txt, doc, etc. that are
grouped into directories. File systems consist of different files which are grouped into
directories.

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

Problems:
 No standards
 Data duplication
 Data dependence
 No way to generate ad hoc queries
 No provision for security, recovery, concurrency, etc.
To overcome these problems the Data base system was implemented.

Difference between File System and DBMS:


Basis File System DBMS

The file system is software that manages


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

Data Redundant data can be present in a file In DBMS there is no redundant


Redundancy system. data.

Backup and It doesn’t provide backup and recovery of It provides backup and recovery
Recovery data if it is lost. of data even if it is lost.

Query There is no efficient query processing in the Efficient query processing is


processing file system. there in DBMS.

There is more data consistency


There is less data consistency in the file because of the process of
Consistency system. normalization.

It has more complexity in


handling as compared to the file
Complexity It is less complex as compared to DBMS. system.

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

Basis File System DBMS

DBMS has more security


Security File systems provide less security in mechanisms as compared to file
Constraints comparison to DBMS. systems.

It has a comparatively higher


Cost It is less expensive than DBMS. cost than a file system.

Data In DBMS data independence


Independence There is no data independence. exists.

Multiple users can access data at


User Access Only one user can access data at a time. a time.

DATABASE SYSTEM
A database is an organized collection of structured data, typically stored electronically in a
computer system.
A database is usually controlled by a database management system (DBMS). Together, the data
and the DBMS, along with the applications that are associated with them, are referred to as a
database system, often shortened to just database.

Example Databases:
• Medical records
• Bank accounts
• Stock control
• Personnel systems
• Product catalogues
• Telephone directories
• Train timetables
Why Database?
A Data Base Management System is a system software for easy, efficient and reliable data processing and
management.
A database system consists of
 Data (the database)
 Software
 Hardware
 Users

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

It can be used for:


 Creation of a database.
 Retrieval of information from the database.
 Updating the database.
 Managing a database.

Benefits of Database Approach:


The data can saved
 Redundancy can be reduced
 In-consistency can be avoided
 Transaction support can be provided
 Integrity can be maintained
 Security can be enforced
 Conflicting requirements can be balanced
 Standards can be enforced

1) Processing Queries and Object Management:


2) Controlling redundancy and inconsistency:
3) Efficient memory management and indexing:
4) Concurrency control and transaction management:
5) Access Control and ease in accessing data:
6) Integrity constraints:
Applications of DBMS
Applications of DBMS: There are various fields where a database management system is
used. Following are some applications which make use of the database management
system:

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

DATABASE USERS
In large organizations, many people are involved in the design, use, and maintenance of a large
database with hundreds of users. The people whose jobs involve the day-to-day use of a large
database; we call them the actors on the scene.
we consider people who may be called workers behind the scene—those who work to maintain
the database system environment but who are not actively interested in the database contents as
part of their daily job.
Database users are categorized based up on their interaction with the data base.
These are seven types of data base users in DBMS.
1. Database Administrator (DBA) :

 Database Administrator (DBA) is a person/team who defines the schema and also
controls the 3 levels of database.

 The DBA will create a user account id and password for the user if he/she need to access
the data base.

 DBA is responsible for providing security to the data base and allows only the authorized
users to access/modify the data base.

 DBA monitors the recovery and back up and provide technical support.

 The DBA has a DBA account in the DBMS which called a system or superuser account.

 DBA repairs damage caused due to hardware and/or software failures.


2. Naive / End Users :
End Users are the unsophisticated who don’t have any DBMS knowledge but they frequently
use the data base applications in their daily life to get the desired results.
For examples, Railway’s ticket booking users are naive users. Clerks in any bank is a naive
user because they don’t have any DBMS knowledge but they still use the database and
perform their given task.
3. System Analyst :
System Analyst is a user who analyzes the requirements of parametric end users. They check
whether all the requirements of end users are satisfied.
4. Sophisticated Users :
Sophisticated users can be engineers, scientists, business analyst, who are familiar with the
database. They can access the database by using their own sql queries.
5. Data Base Designers :
Data Base Designers are the users who design the structure of data base which includes
tables, indexes, views, constraints, triggers, stored procedures. He/she controls what data
must be stored and how the data items to be related.

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

6. Application Programmer :
Application Program are the back end programmers who writes the code for the application
programs.They are the computer professionals. These programs could be written in
Programming languages such as Visual Basic, Developer, C, FORTRAN, COBOL etc.
7. Casual Users / Temporary Users :
Casual Users are the users who occasionally use/access the data base .

Actors on the Scene


In large organizations, many people are involved in the design, use, and maintenance of a large
database with hundreds of users. The people whose jobs involve the day-to-day use of a large
database; we call them the actors on the scene.
Example:
1. Database Administrators
2. Database Designers
3. End Users
4. System Analysts and Application Programmers
Workers behind the Scene
In addition to those who design, use, and administer a database, others are associated with the
design, development, and operation of the DBMS software and system environment. These
persons are typically not interested in the database content itself. We call them the workers
behind the scene.
Example:
1.DBMS system designers and implementers
2.Tool developers
3.Operators and maintenance personnel

Concepts of Schema
A schema can be defined as the design of a database. The overall description of the database is
called the database schema.
The schema also called as Blue Print or skeleton of the database.
It can be categorized into three parts. These are:
1. Physical Schema 2. Logical Schema 3. View Schema

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

Physical Schema: It specifies physical storage structure of the database.


It is used to define that how the data will be stored in a block.
The physical level is used to describe complex low-level data structures in detail.
Logical Schem(Conceptual schema):This schema defines all the logical constraints that need to
be applied on the data stored. It defines tables, views, and integrity constraints.
View schema(External Schema): It can be defined as the design of the database at the view
level, which generally describes end-user interaction with database systems.

DBMS Instance
The data stored in database at a particular moment of time is called instance of database.
Database schema defines the variable declarations in tables that belong to a particular database;
the value of these variables at a moment of time is called the instance of that database.
For example, lets say we have a single table student in the database, today the table has 100
records, so today the instance of the database has 100 records.

Data Independence
Data Independence is defined as a property of DBMS that helps you to change the Database
schema at one level of a database system without requiring to change the schema at the next
higher level.
Data independence helps you to keep data separated from all programs that make use of it.

Types of Data Independence


In DBMS there are two types of data independence

1. Physical data independence


2. Logical data independence.

Logical Data Independence


Logical Data Independence is the ability to change the conceptual scheme without changing
1. External views

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

2. External API or programs


Any change made will be absorbed by the mapping between external and conceptual levels.
Examples of changes under Logical Data Independence
Due to Logical independence, any of the below change will not affect the external layer.
1. Add/Modify/Delete a new attribute, entity or relationship is possible without a rewrite of
existing application programs
2. Merging two records into one
3. Breaking an existing record into two or more records
Physical Data Independence
Physical data independence helps you to separate conceptual levels from the internal/physical
levels. Physical data independence is the power to change the physical data without impacting
the schema or logical data.

Examples of changes under Physical Data Independence


Due to Physical independence, any of the below change will not affect the conceptual layer.
 Using a new storage device like Hard Drive or Magnetic Tapes
 Modifying the file organization technique in the Database
 Switching to different data structures.
 Changing the access method.
 Modifying indexes.
 Changes to compression techniques or hashing algorithms.
 Change of Location of Database from say C drive to D Drive
Importance of Data Independence
 Helps you to improve the quality of the data
 Database system maintenance becomes affordable
 Enforcement of standards and improvement in database security
 You don't need to alter data structure in application programs
 Permit developers to focus on the general structure of the Database rather than worrying
about the internal implementation
 Easily make modifications in the physical level is needed to improve the performance of
the system.

DBMS Architectures
DBMS architectures are 3 types:
Centralized DBMS(1-tier)
Client-Server Architecture (2-tier)
Client-Server Architecture (3-tier)

Centralized DBMS:
Combines everything into single system
includingDBMS software, hardware, application
programs, and user interface processing software.
User can still connect through a remote terminal –
however, all processing is done at centralized site.

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

2-tier Client-Server Architectures:


The client/server architecture was
developed to deal with computing
environments in which a large number
of PCs, work stations, file servers,
printers, data base servers, web servers,
e-mail servers, and others are
connected via a network.

In this, software components are


distributed over two systems: client and server.
Clients:
Provide appropriate interfaces through a client software module to access and utilize the various
server resources.
DBMS Server:
DBMS Server provides database query and transaction services to the clients.
Applications running on clients utilize an Application Program Interface (API) to access server
databases via standard interface such as:
 ODBC : Open Database Connectivity standard
 JDBC: for Java programming access
 Client and server must install appropriate client module and server module software for
ODBC or JDBC
The user interface programs and application programs can run on the client side. When DBMS
access is required, the program establishes a connection to the DBMS, then client program can
communicate with DBMS.
Three Tier Client-Server Architecture:
Many web applications use an architecture called the 3-tier architecture, which adds an
intermediate layer between the client and database server as shown below.

The intermediate layer or middle layer is called Application Server or Web Server, depending
on the application.

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

This server plays an intermediary role by running application programs and storing business
rules that are used to access data from the server.
It can also improve database security by checking client’s credentials before forwarding request
to the database server.
Figure (b) shows another architecture used by some other vendors. The layers in this are
Presentation, Business and Database services layers.
Advantages of Three-Tier Architecture :
1. The key three-tier benefit is improved scalability, since the application servers can be
deployed on many machines. Also, the database does not make longer connections with
every client – it only requires connections from a smaller number of application servers.
2. It improves data integrity. Here, all the updated information goes through the second
tier. The second tier can ensure that only important information is allowed to be updated in
the database and the risk of unreliable client applications corrupting information is
removed.
3. Security is improved since the client does not have direct access to the database; it is
more difficult for a client to obtain unauthorized data. Business logic is more secure
because it is stored on a secure central server.
4. Balancing of load is much easier with division of core business from the server of the
database.

Disadvantages of Three-Tier Architecture:


1. It is more complex than the 2-tier client-server computing model, because it is more
difficult to build a 3-tier application compared to a 2-tier application. The points of
communication are doubled.
2. The client does not maintain a persistent database connection.
3. A separate proxy server may be required.

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

DATABASE SYSTEM STRUCTURE:


A database system is partitioned into modules that deal with each of the responsibilities of the
overall system.

The database system have 4 components:


1) Database users
2) Query processor
3) Storage manager
4) Disk Storage
The query processor is important because it helps the database system simplify and facilitate
access to data. The storage manager is important because databases typically require a large
amount of storage space.
Database Users:
Users are differentiated by the way they expect to interact with the system:

 Naive users are interact with the system by invoking one of the application programs that
have been written previously.

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

 Application programmers are computer professionals who write application programs.


Application programmers can choose from many tools to develop user interfaces.
 Sophisticated users interact with the system without writing programs. Instead, they form
their requests in a database query language.
 Coordinates all the activities of the database system. The database administrator interacts
with DBMS by using administration tools.

Query Processor:
The query processor will accept query from user and solves it by accessing the database.
Parts of Query processor:
 DDL interpreter
This will interprets DDL statements and fetch the definitions in the data dictionary.
 DML compiler
a. This will translates DML statements in a query language into low level instructions
that the query evaluation engine understands.
b. A query can usually be translated into any of a number of alternative evaluation plans
for same query result DML compiler will select best plan for query optimization.
 Query evaluation engine
This engine will execute low-level instructions generated by the DML compiler on
DBMS.
Storage Manager:

 A storage manager is a program module which acts like interface between the data stored
in a database and the application programs and queries submitted to the system.
 Thus, the storage manager is responsible for storing, retrieving and updating data in the
database.
 The storage manager components include:
o Authorization and integrity manager: Checks for integrity constraints and
authority of users to access data.
o Transaction manager: Ensures that the database remains in a consistent state
although there are system failures.
o File manager: Manages the allocation of space on disk storage and the data
structures used to represent information stored on disk.
o Buffer manager: It is responsible for retrieving data from disk storage into main
memory. It enables the database to handle data sizes that are much larger than the
size of main memory.
Disk Storage:
Disk storage is useful to store the actual database which maintains the following:

o Data files: Stored in the database itself.


o Data dictionary: Stores metadata about the structure of the database. The data
dictionary contains records about other objects in the database, such as
data ownership, data relationships to other objects, and other data.
o Indices: Provide fast access to data items.

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

Structured Query Language (SQL)

SQL is a database language designed for the retrieval and management of data in a relational
database. SQL stands for Structured Query Language.
SQL includes database creation, deletion, fetching rows, modifying rows, etc.

Applications of SQL

As mentioned before, SQL is one of the most widely used query language over the databases.
Allows users to access data in the relational database management systems.
 Allows users to describe the data.
 Allows users to define the data in a database and manipulate that data.
 Allows to embed within other languages using SQL modules, libraries & pre-compilers.
 Allows users to create and drop databases and tables.
 Allows users to create view, stored procedure, functions in a database.
 Allows users to set permissions on tables, procedures and views.
SQL databases:
 Microsoft SQL
 MySQL
 MariaDB
 Oracle
 PostgreSQL
 MSSQL
SQL Command categories:
SQL has the following categories of commands used for managing the databases
1. Data Definition Language (DDL)
 CREATE
 DROP
 ALTER
 TRUNCATE
 RENAME
2. Data Manipulation Language (DML)
 INSERT
 UPDATE
 DELETE
3. Data Query Language (DQL)
 SELECT
4. Transational Control Language (TCL)
 GRANT
 REVOKE
5. Data Control Language (DCL)
 COMMIT
 ROLLBACK
 SAVEPOINT

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

DATA TYPES:
1. CHAR(Size): This data type is used to store character string values of fixed length. The
maximum number of character is 255 characters.

2. VARCHAR(Size) / VERCHAR2(Size): This data type is used to store variable length


string data. The maximum character can hold is 2000 character.

3. NUMBER(P, S): The NUMBER data type is used to store number (fixed or floating
point).
P is precision and S is scale.
 The precision is the number of digits in a number. It ranges from 1 to 38.
 The scale is the number of digits to the right of the decimal point in a number. It ranges
from -84 to 127.
For example, the number 1234.56 has a precision of 6 and a scale of 2. So to store this number,
you need NUMBER(6,2).
P and S are optional.
4. INT(size) or INTEGER(size) , FLOAT, DOUBLE, DECIMAL are also used
5. DATE: This data type is used to represent date and time. The standard format is DD-
MM- YY as in 17-SEP-2009.
6. RAW: The RAW data type is used to store binary data, such as digitized picture or
image.
7. BOOL or BOOLEAN : True or false

DDL(Data Definition Language)


DDL commands are used to work on database objects like TABLE, VIEW, SYNONYM, etc.
CREATE – is used to create the database or its objects (like table, index, function, views, store
procedure and triggers).
CREATE TABLE command is used to create a table definition (structure)
Syntax:
CREATE TABLE tablename
(
column1 datatype(size),
column2 datatype(size),
column3 datatype(size),
.....
columnN datatype(size)
);

EXAMPLE:
SQL> Create table student
(
rollno varchar2(10),
name varchar2(10),

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

dob date,
city varchar2(10)
);
ALTER-is used to alter the structure of the database.
ALTER TABLE command is used to modify the column data types, size and add or delete
columns.

Syntax1: To add new columns


Alter table tablename add (column datatype(size), ...);
Syntax2: To modify size(increase only) or change data type
Alter table tablename modify (column datatype(size));
Syntax3: To delete an empty column
Alter table tablename drop column columnname;
Syntax4:To rename a column
Alter table tablename rename column oldcolumn_name to Newcolumn_name;

Example 1:Add pincode column


SQL>alter table student add (pin number (10));
Example 2:To modify size of Name
SQL>alter table student modify (name varchar2 (15));
Example 3:To delete pincode column
SQL>alter table student drop column pin;
Example 4: To change name to stname
SQL>Alter table student rename column name to sname;

DROP – is used to delete objects from the database.


DROP TABLE command is used to delete the entire table including all rows and structure.
Syntax: Drop table tablename;
Example:
SQL>Drop table student;

TRUNCATE– The TRUNCATE TABLE command deletes the data inside a table, but
not the table itself.
Syntax: Truncate table tablename;
Example:
SQL> Truncate table student

RENAME –is used to rename an object existing in the database.

RENAME old_table _name To new_table_name ;


Example;
RENAME student To cseclass;

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

DML(Data Manipulation Language):


These commands that deals with the manipulation of data present in the database.

INSERT – is used to insert data into a table.


Syntax: INSERT INTO TABLENAME(COLUMN NAMES) VALUES(VALUES);
Example 1:To insert specific column values
INSERT INTO STUDENT (rollno, name, city) values (‘591’, ‘RAMU’, ‘GNT’);
Example 2: To insert all column values
INSERT INTO STUDENT values (‘592’, ‘RAMU’, ’11-JAN-1999’, ‘GNT’);

UPDATE – is used to update existing data within a table.


Syntax : UPDATE TABLENAME SET columnName=new value, .. WHERE condition;
Example:
UPDATE STUDENT SET city=’GUNTUR’ WHERE rollno=’591’;
DELETE – is used to delete records from a database table.
Syntax : DELETE FROM TABLENAME WHERE CONDITION
Example: DELETE FROM STUDENT where rollno=’591’;
DQL (Data Query Language) :
DQL commands are used for performing queries on the data within schema objects(Tables).

SELECT – is used to retrieve data from the database.


Syntax: SELECT column names/expressions FROM table names
WHERE condtion
ORDER BY column ASC| DESC
If we use * symbol after SELECT command will display all colomn values.
WHERE Clause is useful to give the condition.
ORDER BY clause is useful to display records either in ascending or descending order.
ORDER BY clause by display in ascending order where ASC is optional.
Examples:
SELECT * FROM STUDENT;
SELECT rollno, name FROM STUDENT;
SELECT * FROM STUDENT WHERE rollno=’591’;
SELECT * FROM STUDENT ORDER BY name ASC;

DCL(Data Control Language):


DCL includes commands deal with the rights, permissions and other controls of the database
system.

GRANT-gives user’s access privileges to the database.


Syntax: GRANT privileges ON TABLENAME TO username;
Example: GRANT SELECT, UPDATE ON STUDENT TO user100;

REVOKE-withdraw user’s access privileges given by using the GRANT command.


Syntax: REVOKE privileges ON TABLENAME FROM username;
Example: REVOKE UPDATE ON STUDENT FROM user100;

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur


Database Management System B.Tech(CSE) II Year II Sem

TCL(transaction Control Language):


TCL commands deal with the transaction within the database.

COMMIT– commits a Transaction.


Syntax: COMMIT;
ROLLBACK– rollbacks a transaction in case of any error occurs.
Syntax: ROLLBACK or ROLLBACK TO SAVEPOINT_LABEL;

SAVEPOINT–sets a savepoint within a transaction.


Syntax: SAVEPOINT LABEL_NAME;
Example: SAVEPOINT A;
SAVEPOINT B
The following rollbacks the transactions upto savepoint ‘B’;
ROLLBACK TO B;

Prepared by Ch Samsonu, Assoc.Professor, CSED,KHIT, Guntur

You might also like