DBMS Unit 1
DBMS Unit 1
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.
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.
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.
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
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.
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 .
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
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.
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.
The intermediate layer or middle layer is called Application Server or Web Server, depending
on the application.
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.
Naive users are interact with the system by invoking one of the application programs that
have been written previously.
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:
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
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.
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
EXAMPLE:
SQL> Create table student
(
rollno varchar2(10),
name varchar2(10),
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.
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