RDBMS Unit 1 Notes
RDBMS Unit 1 Notes
What is Database?
A database is a collection of related data, so that it can be easily stored, accessed and
managed.
In a data base system – a common data is shared by a number of applications and
program independent.
You can organize data into tables, rows, columns, and index it to make it easier to find
relevant information from the database.
A database can be Local, meaning that it can be used on one machine by one user only.
A database can be distributed, meaning that the information is stored on remote
machines and can be accessed over a network. The primary advantage of using
distributed databases is that they can be accessed by multiple users at once.
Define DBMS
A Database-Management System (DBMS) is a collection of interrelated data and a set of
programs to access those data.
The collection of data, usually referred to as the database, contains information relevant
to an enterprise.
Database systems are designed to manage large bodies of information.
The primary goal of a DBMS is to provide a way to store and retrieve database
information that is both convenient and efficient.
1
4. Atomicity of updates
5. Concurrent access
6. Security problems
7. Supports multiple views of data.
3. Data isolation:
Data are isolated in several fields in the same database.
4.Atomicity of updates:
In case of power failure, the database might lose data. So, this feature will automatically prevent
data loss.
5. Concurrent access:
Users can have multiple access to the database at the same time.
6. Security problems:
Database systems will make the restricted access. So, the data will not be vulnerable.
2
Discuss View of Data.
A major purpose of a database system is to provide users with an abstract view of the data. That is,
the system hides certain details of how the data are stored and maintained. The database is highly
complex data. Developers hide the complexity of data structure which might not be familiar with the
end-users. So, they provide abstract views of data. This is called data abstraction. There are 3 levels
of abstraction. They are:
1. Physical level
2. Logical Level
3. View Level
1. Physical Level:
It is called the lowest level of abstraction or internal level. It describes how the data is actually stored
in the database. At this level, complex data structure details are shown.
2. Logical Level
It is called the middle level of abstraction or conceptual level. It describes what data is stored in a
database and also shows what relationship exists among those data.
3. View Level
It is called the highest level of abstraction or external level. It describes the user interaction with
database systems via application programs, that hide details of data types. It shows only a part of
the entire database.
3
Instance
The collection of information stored in the database at a particular moment is called an instance
of the database.
Discuss Schemas.
The overall design of the database is called the database schema. Schemas are changed
infrequently, if at all.
Database systems have several schemas, partitioned according to the levels of abstraction.
There are Three types in Schema.
1.Physical schema
2.Logical schema
3. Subschemas
The physical schema describes the database design at the physical level.
The logical schema describes the database design at the logical level.
A database may also have several schemas at the view level, sometimes called
subschemas, that describe different views of the database.
1. Hierarchical Model
2. Network Model
3. Entity-relationship Model
4. Relational Model.
5. Object-Based Data Model
6. Semistructured Data Model.
4
1. Hierarchical Model
This database model organises data into a tree-like-structure, with a single root, to which all the
other data is linked. The hierarchy starts from the Root data, and expands like a tree, adding
In this model, a child node will only have a single parent node.
This model efficiently describes many real-world relationships like index of a book, recipes etc.
In hierarchical model, data is organised into tree-like structure with one one-to-many relationship
between two different types of data, for example, one department can have many courses, many
2. Network Model
This is an extension of the Hierarchical model. In this model data is organised more like a graph,
In this database model data is more related as more relationships are established in this database
model. Also, as the data is more related, hence accessing the data is also easier and fast. This
This was the most widely used database model, before Relational Model was introduced.
5
Figure : Network Model
3. Entity-relationship Model
In this database model, relationships are created by dividing object of interest into entity and its
characteristics into attributes.
Different entities are related using relationships.
E-R Models are defined to represent the relationships into pictorial form to make it easier for
different stakeholders to understand.
This model is good to design a database, which can then be turned into tables in relational
model(explained below).
Let's take an example, If we have to design a School Database, then Student will be
an entity with attributes name, age, address etc. As Address is generally complex, it can be
another entity with attributes street name, pincode, city etc, and there will be a relationship
between them.
6
4. Relational Model
In this model, data is organised in two-dimensional tables and the relationship is maintained by
storing a common field.
This model was introduced by E.F Codd in 1970, and since then it has been the most widely used
database model, infact, we can say the only database model used around the world.
The basic structure of data in the relational model is tables. All the information related to a
particular type is stored in rows of that table.
Hence, tables are also known as relations in relational model.
Object-oriented programming (especially in Java, C++, or C#) has become the dominant software-
development methodology. This led to the development of an object-oriented data model that can be
seen as extending the E-R model with notions of encapsulation, methods (functions), and object identity.
The object-relational data model combines features of the object-oriented data model and relational data
model.
The semistructured data model permits the specification of data where individual data items of the same
type may have different sets of attributes. The Extensible Markup Language (XML) is widely used to
represent semistructured data.
7
Discuss Database languages.
SQL Commands
SQL commands are instructions. It is used to communicate with the database. It is also used to perform
specific tasks, functions, and queries of data.
SQL can perform various tasks like create a table, add data to tables, drop the table, modify the table, set
permission for users.
8
There are two CREATE statements available in SQL:
CREATE DATABASE
CREATE TABLE
Example Query:
CREATE DATABASE II_B.COM_CA;
CREATE TABLE
The CREATE TABLE statement is used to create a table in SQL. We know that a table comprises of
rows and columns. So while creating tables we have to provide all the information to SQL about the
names of the columns, type of data to be stored in columns, size of the data.
syntax:
Example Query:
This query will create a table named Students with three columns, ROLL_NO, NAME and SUBJECT.
9
NAME varchar(20),
ADDRESS varchar(50),
);
DROP: It is used to delete both the structure and record stored in the table.
Syntax
DROP TABLE table_name;
Example
DROP TABLE Students;
Syntax:
To add a new column in the table
TRUNCATE: It is used to delete all the rows from the table and free the space containing the table.
Syntax:
10
Discuss Transaction Management.
11
2. Transaction manager
It ensures that the database remains in a consistent (correct) state despite system failures, and
that concurrent transaction executions proceed without conflicting.
3. File manager
It manages the allocation of space on disk storage and the data structures used to represent
information stored on disk.
4. Buffer manager
It is responsible for fetching data from disk storage into main memory, and deciding what data
to cache in main memory. The buffer manager is a critical part of the database system, since it
enables the database to handle data sizes that are much larger than the size of main memory.
Database Users
Users are differentiated by the way they expect to interact with the system
Application programmers – interact with system through DML calls
Sophisticated users – form requests in a database query language
Specialized users – write specialized database applications that do not fit into the
traditional data processing framework
Naïve users – invoke one of the permanent application programs that have been written
previously
E.g. people accessing database over the web, bank tellers, clerical Staff
12
Discuss Three-Schema Architecture.
The goal of the three-schema architecture is to separate the user applications and the physical
database. In this architecture, schemas can be defined at the following three levels:
1. Internal Level Schema
2. Conceptual Level Schema
3. External or View Level Schema
13
Discuss Two-Tier Architecture and Three Tier Architecture.
Two-Tier Architecture
In a two-tier architecture, the application resides at the client machine, where it invokes database
system functionality at the server machine through query language statements. Application
program interface standards like ODBC and JDBC are used for interaction between the client and
the server.
Three-Tier Architecture
In contrast, in a three-tier architecture, the client machine acts as merely a front end and does not
contain any direct database calls. Instead, the client end communicates with an application server,
usually through a forms interface. The application server in turn communicates with a database
system to access data. Three-tier applications are more appropriate for large applications, and
14
Describe Database System Architecture in detail.
A database system is partitioned into modules that deal with each of the responsibilities
of the overall system.
The functional components of a database system can be broadly divided into the storage
manager and the query processor components.
The storage manager is important because databases typically require a large amount of
storage space. The query processor is important because it helps the database system
simplify and facilitate access to data.
Query Processor:
The Query Processor consists of DDL Interpreter, DML Compiler, Query evaluation engine.
DDL interpreter
It interprets DDL statements and records the definitions in the data dictionary.
DML compiler,
It translates DML statements in a query language into an evaluation plan consisting of
low-level instructions that the query evaluation engine understands.
The DML compiler also performs query optimization, that is, it picks the lowest cost
evaluation plan from among the alternatives.
Storage Manager:
A storage manager is a program module that provides the interface between the low level data
stored in the database and the application programs and queries submitted to the system. The
storage manager is
responsible for the interaction with the file manager.
.
The storage manager components include:
1. Authorization and integrity manager
15
It tests for the satisfaction of integrity constraints and checks the authority of users to access data.
2. Transaction manager
It ensures that the database remains in a consistent (correct) state despite system failures, and
that concurrent transaction executions proceed without conflicting.
3. File manager
It manages the allocation of space on disk storage and the data structures used to represent
information stored on disk.
4· Buffer manager
It is responsible for fetching data from disk storage into main memory, and deciding what data to
cache in main memory. The buffer manager is a critical part of the database system, since it
enables the database to handle data sizes that are much larger than the size of main memory.
Transaction Manager:
A transaction is a collection of operations that performs a single logical function in a database
application. If the database was consistent when a transaction started, the database must be
consistent when the transaction successfully terminates. Transaction - manager ensures that the
database remains in a consistent (correct) state despite system failures (e.g., power failures and
operating system crashes) and transaction failures.
16
Figure : Overall System Architecture
1. Enterprise Information
17
Manufacturing: For management of the supply chain and for tracking production of items
in factories, inventories of items in warehouses and stores, and orders for items.
Online retailers: For sales data noted above plus online order tracking, generation of
recommendation lists, and maintenance of online product evaluations.
3. Universities:
For student information, course registrations, and grades (in addition to standard enterprise
information such as human resources and accounting).
4. Airlines:
For reservations and schedule information. Airlines were among the first to use databases in a
geographically distributed manner.
5 Telecommunication:
For keeping records of calls made, generating monthly bills, maintaining balances on prepaid
calling cards, and storing information about the communication networks.
18