Dbms Chapter1
Dbms Chapter1
What is Database
The database is a collection of inter-related data which is used to retrieve, insert and
delete the data efficiently. It is also used to organize the data in the form of a table,
schema, views, and reports, etc.
For example: The college Database organizes the data about the admin, staff, students
and faculty etc.
Using the database, you can easily retrieve, insert, and delete the information.
● Data Updation: It is used for the insertion, modification, and deletion of the
actual data in the database.
● Data Retrieval: It is used to retrieve the data from the database which can be
used by applications for various purposes.
Characteristics of DBMS
● It can provide a clear and logical view of the process that manipulates data.
● Database
A database is a named collection of tables. (see table). A database can also contain views,
indexes, sequences, data types, operators, and functions. Other relational database
products use the term catalog.
● Command
A command is a string that you send to the server in hopes of having the server do
something useful. Some people use the word statement to mean command. The two words
are very similar in meaning and, in practice, are interchangeable
● Query
A query is a type of command that retrieves data from the server.
● Table (relation, file, class)
A table is a collection of rows. A table usually has a name, although some tables are
temporary and exist only to carry out a command. All the rows in a table have the same
shape (in other words, every row in a table contains the same set of columns). In other
database systems, you may see the terms relation, file, or even class?these are all
equivalent to a table.
● Column (field, attribute)
A column is the smallest unit of storage in a relational database. A column represents one
piece of information about an object. Every column has a name and a data type. Columns
are grouped into rows, and rows are grouped into tables. In Figure 1.1, the shaded area
depicts a single column.
Figure 1.1. A column (highlighted).
You may also see the terms record or tuple?these are equivalent to a row.
● View
A view is an alternative way to present a table (or tables). You might think of a view as a
"virtual" table. A view is (usually) defined in terms of one or more tables. When you create a
view, you are not storing more data, you are instead creating a different way of looking at
existing data. A view is a useful way to give a name to a complex query that you may have
to use repeatedly.
● Client/server
PostgreSQL is built around a client/server architecture. In a client/server product, there are
at least two programs involved. One is a client and the other is a server. These programs
may exist on the same host or on different hosts that are connected by some sort of
network. The server offers a service; in the case of PostgreSQL, the server offers to store,
retrieve, and change data. The client asks a server to perform work; a PostgreSQL client
asks a PostgreSQL server to serve up relational data.
● Client
A client is an application that makes requests of the PostgreSQL server. Before a client
application can talk to a server, it must connect to a postmaster (see postmaster) and
establish its identity. Client applications provide a user interface and can be written in many
languages. Chapters 8 through 17 will show you how to write a client application.
● Server
The PostgreSQL server is a program that services commands coming from client
applications. The PostgreSQL server has no user interface?you can't talk to the server
directly, you must use a client application.
● Postmaster
Because PostgreSQL is a client/server database, something has to listen for connection
requests coming from a client application. That's what the postmaster does. When a
connection request arrives, the postmaster creates a new server process in the host
operating system.
● Transaction
A transaction is a collection of database operations that are treated as a unit. PostgreSQL
guarantees that all the operations within a transaction complete or that none of them
complete. This is an important property?it ensures that if something goes wrong in the
middle of a transaction, changes made before the point of failure will not be reflected in the
database. A transaction usually starts with a BEGIN command and ends with a COMMIT or
ROLLBACK (see the next entries).
● Commit
A commit marks the successful end of a transaction. When you perform a commit, you are
telling PostgreSQL that you have completed a unit of operation and that all the changes
that you made to the database should become permanent.
● Rollback
A rollback marks the unsuccessful end of a transaction. When you roll back a transaction,
you are telling PostgreSQL to discard any changes that you have made to the database
(since the beginning of the transaction).
● Index
An index is a data structure that a database uses to reduce the amount of time it takes to
perform certain operations. An index can also be used to ensure that duplicate values don't
appear where they aren't wanted. I'll talk about indexes in Chapter 4, "Query Optimization."
● Result set
When you issue a query to a database, you get back a result set. The result set contains all
the rows that satisfy your query. A result set may be empty.
Consider an example of a student's file system. The student file will contain
information regarding the student (i.e. roll no, student name, course etc.). Similarly, we
have a subject file that contains information about the subject and the result file which
contains the information regarding the result.
Some fields are duplicated in more than one file, which leads to data redundancy. So to
overcome this problem, we need to create a centralized system, i.e. DBMS approach.
12M
195
DBMS:
A database approach is a well-organized collection of data that are related in a
meaningful way which can be accessed by different users but stored only once in a
system. The various operations performed by the DBMS system are: Insertion,
deletion, selection, sorting etc.
In the above figure,
There are the following differences between DBMS and File systems:
DBMS, the user is not required to data. In this system, the user has
Data DBMS gives an abstract view of The file system provides the detail
Abstraction data that hides the details. of the data representation and
storage of data.
Security DBMS provides a good It isn't easy to protect a file under
Protection
Recovery DBMS provides a crash recovery The file system doesn't have a
Manipulatio DBMS contains a wide variety of The file system can't efficiently
y Problems access of data using some form access has many problems like
some information.
ce be of two types.
● Logical Data
Independence
● Physical Data
Independence
exists.
● Hierarchal data models
approach.
Codd's Rules
Every database has tables, and constraints cannot be referred to as a rational database
system. And if any database has only relational data model, it cannot be a Relational
Database System (RDBMS)
. So, some rules define a database to be the correct RDBMS. These rules were developed by
Dr. Edgar F. Codd (E.F. Codd) in 1985, who has vast research knowledge on the Relational
Model of database Systems. Codd presents his 13 rules for a database to test the concept of
DBMS
against his relational model, and if a database follows the rule, it is called a true relational
database (RDBMS). These 13 rules are popular in RDBMS, known as Codd's 12 rules.
Rule 0: The Foundation Rule
The database must be in relational form. So that the system can handle the database
through its relational capabilities.
A database contains various information, and this information must be stored in each
cell of a table in the form of rows and columns.
Keep Watching
This rule defines the systematic treatment of Null values in database records. The null
value has various meanings in the database, like missing the data, no value in a cell,
inappropriate information, unknown data and the primary key should not be null.
It represents the entire logical structure of the descriptive database that must be
stored online and is known as a database dictionary. It authorizes users to access the
database and implement a similar query language to access the database.
The relational database supports various languages, and if we want to access the
database, the language must be the explicit, linear or well-defined syntax, character
strings and supports the comprehensive: data definition, view definition, data
manipulation, integrity constraints, and limit transaction management operations. If
the database allows access to the data without any language, it is considered a
violation of the database.
All views table can be theoretically updated and must be practically updated by the
database systems.
A database must maintain integrity independence when inserting data into table's cells
using the SQL query language. All entered values should not be changed or rely on any
external factor or application to maintain integrity. It is also helpful in making the
database-independent for each front-end application.
The distribution independence rule represents a database that must work properly,
even if it is stored in different locations and used by different end-users. Suppose a
user accesses the database through an application; in that case, they should not be
aware that another user uses particular data, and the data they always get is only
located on one site. The end users can access the database, and these access data
should be independent for every user to perform the SQL queries.
Data Independence
● Data independence can be explained using the three-schema architecture.
● Logical data independence is used to separate the external level from the
conceptual view.
● If we do any changes in the conceptual view of the data, then the user view of
the data would not be affected.
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.
Database architecture can be seen as a single tier or multi-tier. But logically, database
architecture is of two types like: 2-tier architecture and 3-tier architecture.
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
● The user interfaces and application programs are run on the client-side.
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.
● 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 three schema architecture is also used to separate the user applications
and physical database.
● Mapping is not good for small DBMS because it takes more time.
● The approach in which a particular user needs to see the data may change over
time.
● The users of the database should not worry about the physical implementation
and internal workings of the database such as data compression and encryption
techniques, hashing, optimization of the internal structures etc.
● All users should be able to access the same data according to their
requirements.
● DBA should be able to change the conceptual structure of the database without
affecting the user's
1. Internal Level
● The internal level has an internal schema which describes the physical storage
structure of the database.
● It uses the physical data model. It is used to define that how the data will be
stored in a block.
● Access paths.
For Example: Specification of primary and secondary keys, indexes, pointers
and sequencing.
2. Conceptual Level
● The conceptual schema describes the design of a database at the conceptual
level. Conceptual level is also known as logical level.
● The conceptual level describes what data are to be stored in the database and
also describes what relationship exists among those data.
3. External Level
● Each view schema describes the database part that a particular user group is
interested and hides the remaining database from that user group.
● The view schema describes the end user interaction with database systems.
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.
Example
Finally, we can say that the content of database at a point of time is called instance or
database state.
Instance −
Database Language
● A DBMS has appropriate languages and interfaces to express database queries
and updates.
● Database languages can be used to read, store and update the data in the
database.
● DDL stands for Data Definition Language. It is used to define database structure
or pattern.
● Using the DDL statements, you can create the skeleton of the database.
● Data definition language is used to store the information of metadata like the
number of tables and schemas, their names, indexes, columns in each table,
constraints, etc.
Here are some tasks that come under DDL:
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.
(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.
● Rollback: It is used to restore the database to original since the last Commit.
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.