Book Summary
Book Summary
Characteristics of DBMS
Advantages of DBMS
Disadvantages of DBMS
There are various types of databases used for storing different varieties of data:
1) Centralized Database
It has decreased the risk of data management, i.e., manipulation of data will
not affect the core data.
Data consistency is maintained as it manages data in a central repository.
It provides better data quality, which enables organizations to establish data
standards.
It is less costly because fewer vendors are required to handle the data sets.
Disadvantages of Centralized Database
The size of the centralized database is large, which increases the response
time for fetching the data.
It is not easy to update such an extensive database system.
If any server failure occurs, entire data will be lost, which could be a huge
loss.
2) Distributed Database
3) Relational Database
This database is based on the relational data model, which stores data in the form
of rows(tuple) and columns(attributes), and together forms a table(relation). A
relational database uses SQL for storing, manipulating, as well as maintaining the
data. E.F. Codd invented the database in 1970. Each table in the database carries a
key that makes the data unique from others. Examples of Relational databases are
MySQL, Microsoft SQL Server, Oracle, etc.
There are following four commonly known properties of a relational model known as ACID
properties, where:
A means Atomicity: This ensures the data operation will complete either with success or with
failure. It follows the 'all or nothing' strategy. For example, a transaction will either be
committed or will abort.
C means Consistency: If we perform any operation over the data, its value before and after the
operation should be preserved. For example, the account balance before and after the transaction
should be correct, i.e., it should remain conserved.
I means Isolation: There can be concurrent users for accessing data at the same time from the
database. Thus, isolation between the data should remain isolated. For example, when multiple
transactions occur at the same time, one transaction effects should not be visible to the other
transactions in the database.
D means Durability: It ensures that once it completes the operation and commits the data, data
changes should remain permanent.
DBMS Architecture
The DBMS design depends upon its architecture. The basic client/server
architecture is used to deal with a large number of PCs, web servers,
database servers and other components that are connected with networks.
The client/server architecture consists of many PCs and a workstation which
are connected via the network.
DBMS architecture depends upon how users are connected to the database to
get their request done.
1-Tier Architecture
In this architecture, the database is directly available to the user. It means the
user can directly sit on the DBMS and uses it.
Any changes done here will directly be done on the database itself. It doesn't
provide a handy tool for end users.
The 1-Tier architecture is used for development of the local application,
where programmers can directly communicate with the database for the
quick response.
2-Tier Architecture
3-Tier Architecture
The 3-Tier architecture contains another layer between the client and server.
In this architecture, client can't directly communicate with the server.
The application on the client-end interacts with an application server which
further communicates with the database system.
End user has no idea about the existence of the database beyond the
application server. The database also has no idea about any other user
beyond the application.
The 3-Tier architecture is used in case of large web application.
The main objective of three level architecture is to enable multiple users to access
the same data with a personalized view while storing the underlying data only
once. Thus it separates the user's view from the physical structure of the database.
This separation is desirable for the following reasons:
The Conceptual/ Internal Mapping lies between the conceptual level and the
internal level. Its role is to define the correspondence between the records and
fields of the conceptual level and files and data structures of the internal level.
The external/Conceptual Mapping lies between the external level and the
Conceptual level. Its role is to define the correspondence between a particular
external and the conceptual view.
Data Models
Data Model is the modeling of the data description, data semantics, and
consistency constraints of the data. It provides the conceptual tools for describing
the design of a database at each level of data abstraction. Therefore, there are
following four data models used for understanding the structure of the database:
1) Relational Data Model: This type of model designs the data in the form of
rows and columns within a table. Thus, a relational model uses tables for
representing data and in-between relationships. Tables are also called relations.
This model was initially described by Edgar F. Codd, in 1969. The relational data
model is the widely used model which is primarily used by commercial data
processing applications.
4) Semistructured Data Model: This type of data model is different from the
other three data models (explained above). The semistructured data model allows
the data specifications at places where the individual data items of the same type
may have different attributes sets. The Extensible Markup Language, also known
as XML, is widely used for representing the semistructured data. Although XML
was initially designed for including the markup information to the text document, it
gains importance because of its application in the exchange of data.
In the database, actual data changes quite frequently. For example, in the given
figure, the database changes whenever we add a new grade or add a student. The
data at a particular moment of time is called the instance of the database.
Database Language
These commands are used to update the database schema that's why they come
under Data definition language.
DML stands for Data Manipulation Language. It is used for accessing and
manipulating data in a database. It handles user requests.
DCL stands for Data Control Language. It is used to retrieve the stored or
saved data.
The DCL execution is transactional. It also has rollback parameters.
(But in Oracle database, the execution of data control language does not
have the feature of rolling back.)
There are the following operations which have the authorization of Revoke:
TCL is used to run the changes made by the DML statement. TCL can be grouped
into a logical transaction.
SQL
SQL stands for Structured Query Language. It is used for storing and
managing data in relational database management system (RDMS).
It is a standard language for Relational Database System. It enables a user to
create, read, update and delete relational databases and tables.
All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server
use SQL as their standard database language.
SQL allows users to query the database in a number of ways, using English-
like statements.
Rules:
SQL process:
When an SQL command is executing for any RDBMS, then the system
figure out the best way to carry out the request and the SQL engine
determines that how to interpret the task.
In the process, various components are included. These components can be
optimization Engine, Query engine, Query dispatcher, classic, etc.
All the non-SQL queries are handled by the classic query engine, but SQL
query engine won't handle logical files.
Characteristics of SQL
High speed
Using the SQL queries, the user can quickly and efficiently retrieve a large amount
of records from a database.
No coding needed
In the standard SQL, it is very easy to manage the database system. It doesn't
require a substantial amount of code to manage the database system.
Long established are used by the SQL databases that are being used by ISO and
ANSI.
Portability
SQL can be used in laptop, PCs, server and even some mobile phones.
Interactive language
SQL is a domain language used to communicate with the database. It is also used
to receive answers to the complex questions in seconds.
Using the SQL language, the users can make different views of the database
structure.
SQL Datatype
SQL Datatype is used to define the values that a column can contain.
Every column is required to have a name and data type in the database table.
Datatype of SQL:
1. Binary Datatypes
There are Three types of binary Datatypes which are given below:
Data
Description
type
int It is used to specify an integer value.
smallint It is used to specify small integer value.
bit It has the number of bits to store.
decimal It specifies a numeric value that can have a decimal number.
numeric It is used to specify a numeric value.
Data
Description
type
It has a maximum length of 8000 characters. It contains Fixed-length
char
non-unicode characters.
It has a maximum length of 8000 characters. It contains variable-length
varchar
non-unicode characters.
It has a maximum length of 2,147,483,647 characters. It contains
text
variable-length non-unicode characters.
Datatype Description
date It is used to store the year, month, and days value.
time It is used to store the hour, minute, and second values.
timestamp It stores the year, month, day, hour, minute, and the second value.
SQL Commands
There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.
1. Data Definition Language (DDL)
DDL changes the structure of the table like creating a table, deleting a table,
altering a table, etc.
All the command of DDL are auto-committed that means it permanently
save all the changes in the database.
CREATE
ALTER
DROP
TRUNCATE
Example:
b. DROP: It is used to delete both the structure and record stored in the table.
Example
c. ALTER: It is used to alter the structure of the database. This change could be
either to modify the characteristics of an existing attribute or probably to add a new
attribute.
Syntax:
EXAMPLE
d. TRUNCATE: It is used to delete all the rows from the table and free the space
containing the table.
Syntax:
DML commands are used to modify the database. It is responsible for all
form of changes in the database.
The command of DML is not auto-committed that means it can't
permanently save all the changes in the database. They can be rollback.
INSERT
UPDATE
DELETE
a. INSERT: The INSERT statement is a SQL query. It is used to insert data into
the row of a table.
Syntax:
Or
For example:
Syntax:
1. UPDATE table_name SET [column_name1= value1,...column_nameN = val
ueN] [WHERE CONDITION]
For example:
1. UPDATE students
2. SET User_Name = 'Abduljalal'
3. WHERE Student_Id = '3'
Syntax:
For example:
WHERE Author="Abdul";
DCL commands are used to grant and take back authority from any database user.
Grant
Revoke
Example
Example
TCL commands can only use with DML commands like INSERT, DELETE and
UPDATE only.
These operations are automatically committed in the database that's why they
cannot be used while creating tables or dropping them.
COMMIT
ROLLBACK
SAVEPOINT
a. Commit: Commit command is used to save all the transactions to the database.
Syntax:
1. COMMIT;
Example:
b. Rollback: Rollback command is used to undo transactions that have not already
been saved to the database.
Syntax:
1. ROLLBACK;
Example:
1. SAVEPOINT SAVEPOINT_NAME;
SELECT
Syntax:
1. SELECT expressions
2. FROM TABLES
3. WHERE conditions;
For example:
1. SELECT emp_name
2. FROM employee
3. WHERE age > 20;