Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DBMS

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

DBMS Architecture

o 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.
o The client/server architecture consists of many PCs and a workstation which are
connected via the network.
o DBMS architecture depends upon how users are connected to the database to
get their request done.

Types of DBMS Architecture

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
o In this architecture, the database is directly available to the user. It means the
user can directly sit on the DBMS and uses it.
o Any changes done here will directly be done on the database itself. It doesn't
provide a handy tool for end users.
o 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

o The 2-Tier architecture is same as basic client-server. In the two-tier


architecture, applications on the client end can directly communicate with the
database at the server side. For this interaction, API's like: ODBC, JDBC are
used.
o The user interfaces and application programs are run on the client-side.

o The server side is responsible to provide the functionalities like: query processing
and transaction management.
o To communicate with the DBMS, client-side application establishes a connection
with the server side.

o
Fig: 2-tier Architecture

3-Tier Architecture

o The 3-Tier architecture contains another layer between the client and server. In
this architecture, client can't directly communicate with the server.
o The application on the client-end interacts with an application server which
further communicates with the database system.
o 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.
o The 3-Tier architecture is used in case of large web application.
o
Fig: 3-tier Architecture

Three schema Architecture


o The three schema architecture is also called ANSI/SPARC architecture or three-
level architecture.
o This framework is used to describe the structure of a specific database system.

o The three schema architecture is also used to separate the user applications and
physical database.
o The three schema architecture contains three-levels. It breaks the database
down into three different categories.

The three-schema architecture is as follows:


In the above diagram:

o It shows the DBMS architecture.

o Mapping is used to transform the request and response between various


database levels of architecture.
o Mapping is not good for small DBMS because it takes more time.

o In External / Conceptual mapping, it is necessary to transform the request from


external level to conceptual schema.
o In Conceptual / Internal mapping, DBMS transform the request from the
conceptual to internal level.

1. Internal Level

o The internal level has an internal schema which describes the physical storage
structure of the database.
o The internal schema is also known as a physical schema.

o It uses the physical data model. It is used to define that how the data will be
stored in a block.
o The physical level is used to describe complex low-level data structures in detail.

2. Conceptual Level

o The conceptual schema describes the design of a database at the conceptual


level. Conceptual level is also known as logical level.
o The conceptual schema describes the structure of the whole database.

o The conceptual level describes what data are to be stored in the database and
also describes what relationship exists among those data.
o In the conceptual level, internal details such as an implementation of the data
structure are hidden.
o Programmers and database administrators work at this level.

3. External Level
o At the external level, a database contains several schemas that sometimes called
as subschema. The subschema is used to describe the different view of the
database.
o An external schema is also known as view schema.

o Each view schema describes the database part that a particular user group is
interested and hides the remaining database from that user group.
o The view schema describes the end user interaction with database systems.

Database Language
o A DBMS has appropriate languages and interfaces to express database queries
and updates.
o Database languages can be used to read, store and update the data in the
database.

Types of Database Language


1. Data Definition Language

o DDL stands for Data Definition Language. It is used to define database structure
or pattern.
o It is used to create schema, tables, indexes, constraints, etc. in the database.

o Using the DDL statements, you can create the skeleton of the database.

o 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:

o Create: It is used to create objects in the database.

o Alter: It is used to alter the structure of the database.

o Drop: It is used to delete objects from the database.

o Truncate: It is used to remove all records from a table.

o Rename: It is used to rename an object.

o Comment: It is used to comment on the data dictionary.


These commands are used to update the database schema that's why they come under
Data definition language.

2. Data Manipulation Language


DML stands for Data Manipulation Language. It is used for accessing and manipulating
data in a database. It handles user requests.

Here are some tasks that come under DML:

o Select: It is used to retrieve data from a database.

o Insert: It is used to insert data into a table.

o Update: It is used to update existing data within a table.

o Delete: It is used to delete all records from a table.

o Merge: It performs UPSERT operation, i.e., insert or update operations.

o Call: It is used to call a structured query language or a Java subprogram.

o Explain Plan: It has the parameter of explaining data.

o Lock Table: It controls concurrency.

3. Data Control Language

o DCL stands for Data Control Language. It is used to retrieve the stored or saved
data.
o 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.)

Here are some tasks that come under DCL:

o Grant: It is used to give user access privileges to a database.

o Revoke: It is used to take back permissions from the user.

There are the following operations which have the authorization of Revoke:

CONNECT, INSERT, USAGE, EXECUTE, DELETE, UPDATE and SELECT.

4. Transaction Control Language


TCL is used to run the changes made by the DML statement. TCL can be grouped into a
logical transaction.

Here are some tasks that come under TCL:

o Commit: It is used to save the transaction on the database.

o Rollback: It is used to restore the database to original since the last Commit.

ACID Properties in DBMS


DBMS is the management of data that should remain integrated when any changes are
done in it. It is because if the integrity of the data is affected, whole data will get
disturbed and corrupted. Therefore, to maintain the integrity of the data, there are four
properties described in the database management system, which are known as
the ACID properties. The ACID properties are meant for the transaction that goes
through a different group of tasks, and there we come to see the role of the ACID
properties.

In this section, we will learn and understand about the ACID properties. We will learn
what these properties stand for and what does each property is used for. We will also
understand the ACID properties with the help of some examples.

ACID Properties
The expansion of the term ACID defines for:
1) Atomicity: The term atomicity defines that the data remains atomic. It means if
any operation is performed on the data, either it should be performed or executed
completely or should not be executed at all. It further means that the operation should
not break in between or execute partially. In the case of executing operations on the
transaction, the operation should be completely executed and not partially.

Example: If Remo has account A having $30 in his account from which he wishes to
send $10 to Sheero's account, which is B. In account B, a sum of $ 100 is already
present. When $10 will be transferred to account B, the sum will become $110. Now,
there will be two operations that will take place. One is the amount of $10 that Remo
wants to transfer will be debited from his account A, and the same amount will get
credited to account B, i.e., into Sheero's account. Now, what happens - the first
operation of debit executes successfully, but the credit operation, however, fails. Thus,
in Remo's account A, the value becomes $20, and to that of Sheero's account, it
remains $100 as it was previously present.
In the above diagram, it can be seen that after crediting $10, the amount is still $100
in account B. So, it is not an atomic transaction.

The below image shows that both debit and credit operations are done successfully.
Thus the transaction is atomic.

Thus, when the amount loses atomicity, then in the bank systems, this becomes a huge
issue, and so the atomicity is the main focus in the bank systems.

2) Consistency: The word consistency means that the value should remain
preserved always. In DBMS, the integrity of the data should be maintained, which
means if a change in the database is made, it should remain preserved always. In the
case of transactions, the integrity of the data is very essential so that the database
remains consistent before and after the transaction. The data should always be correct.

Example:
In the above figure, there are three accounts, A, B, and C, where A is making a
transaction T one by one to both B & C. There are two operations that take place, i.e.,
Debit and Credit. Account A firstly debits $50 to account B, and the amount in account
A is read $300 by B before the transaction. After the successful transaction T, the
available amount in B becomes $150. Now, A debits $20 to account C, and that time,
the value read by C is $250 (that is correct as a debit of $50 has been successfully
done to B). The debit and credit operation from account A to C has been done
successfully. We can see that the transaction is done successfully, and the value is also
read correctly. Thus, the data is consistent. In case the value read by B and C is $300,
which means that data is inconsistent because when the debit operation executes, it
will not be consistent.

4) Isolation: The term 'isolation' means separation. In DBMS, Isolation is the property
of a database where no data should affect the other one and may occur concurrently. In
short, the operation on one database should begin when the operation on the first
database gets complete. It means if two operations are being performed on two
different databases, they may not affect the value of one another. In the case of
transactions, when two or more transactions occur simultaneously, the consistency
should remain maintained. Any changes that occur in any particular transaction will not
be seen by other transactions until the change is not committed in the memory.

Example: If two operations are concurrently running on two different accounts, then
the value of both accounts should not get affected. The value should remain persistent.
As you can see in the below diagram, account A is making T1 and T2 transactions to
account B and C, but both are executing independently without affecting each other. It
is known as Isolation.
4) Durability: Durability ensures the permanency of something. In DBMS, the term
durability ensures that the data after the successful execution of the operation becomes
permanent in the database. The durability of the data should be so perfect that even if
the system fails or leads to a crash, the database still survives. However, if gets lost, it
becomes the responsibility of the recovery manager for ensuring the durability of the
database. For committing the values, the COMMIT command must be used every time
we make changes.

Therefore, the ACID property of DBMS plays a vital role in maintaining the consistency
and availability of data in the database.

Thus, it was a precise introduction of ACID properties in DBMS. We have discussed


these properties in the transaction section also.

View of Data in DBMS


Abstraction is one of the main features of database systems.
Hiding irrelevant details from user and providing abstract view of
data to users, helps in easy and efficient user-
database interaction. In the previous tutorial, we discussed
the three level of DBMS architecture, The top level of that
architecture is “view level”. The view level provides the “view of
data” to the users and hides the irrelevant details such as data
relationship, database schema, constraints, security etc from
the user.

To fully understand the view of data, you must have a basic


knowledge of data abstraction and instance & schema. Refer
these two tutorials to learn them in detail.

1. Data abstraction
2. Instance and schema

Data Abstraction in DBMS


BY CHAITANYA SINGH | FILED UNDER: DBMS

Database systems are made-up of complex data structures. To


ease the user interaction with database, the developers hide
internal irrelevant details from users. This process of hiding
irrelevant details from user is called data abstraction.
We have three levels of abstraction:
Physical level: This is the lowest level of data abstraction. It
describes how data is actually stored in database. You can get
the complex data structure details at this level.

Logical level: This is the middle level of 3-level data abstraction


architecture. It describes what data is stored in database.

View level: Highest level of data abstraction. This level describes


the user interaction with database system.

Example: Let’s say we are storing customer information in a


customer table. At physical level these records can be
described as blocks of storage (bytes, gigabytes, terabytes etc.)
in memory. These details are often hidden from the programmers.

At the logical level these records can be described as fields and


attributes along with their data types, their relationship among
each other can be logically implemented. The programmers
generally work at this level because they are aware of such
things about database systems.

At view level, user just interact with system with the help of GUI
and enter the details at the screen, they are not aware of how
the data is stored and what data is stored; such details are
hidden from them.

Instance and schema in DBMS


BY CHAITANYA SINGH | FILED UNDER: DBMS

In this guide, we will learn what is an instance and schema in


DBMS.

DBMS Schema
Definition of schema: Design of a database is called the
schema. Schema is of three types: Physical schema, logical
schema and view schema.

For example: In the following diagram, we have a schema that


shows the relationship between three tables: Course, Student
and Section. The diagram only shows the design of the database,
it doesn’t show the data present in those tables. Schema is only
a structural view(design) of a database as shown in the diagram
below.

The design of a database at physical level is called physical


schema, how the data stored in blocks of storage is described at
this level.

Design of database at logical level is called logical schema,


programmers and database administrators work at this level, at
this level data can be described as certain types of data records
gets stored in data structures, however the internal details such
as implementation of data structure is hidden at this level
(available at physical level).

Design of database at view level is called view schema. This


generally describes end user interaction with database systems.
To learn more about these schemas, refer 3 level data
abstraction architecture.

DBMS Instance
Definition of 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. Lets say we are going to add
another 100 records in this table by tomorrow so the instance of
database tomorrow will have 200 records in table. In short, at a
particular moment the data stored in database is called the
instance, that changes over time when we add or delete data
from the database.

Integrity Constraints
o Integrity constraints are a set of rules. It is used to maintain the quality of
information.
o Integrity constraints ensure that the data insertion, updating, and other
processes have to be performed in such a way that data integrity is not affected.
o Thus, integrity constraint is used to guard against accidental damage to the
database.

Types of Integrity Constraint


1. Domain constraints

o Domain constraints can be defined as the definition of a valid set of values for an
attribute.
o The data type of domain includes string, character, integer, time, date, currency,
etc. The value of the attribute must be available in the corresponding domain.

Example:

2. Entity integrity constraints


o The entity integrity constraint states that primary key value can't be null.

o This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those
rows.
o A table can contain a null value other than the primary key field.

Example:

3. Referential Integrity Constraints

o A referential integrity constraint is specified between two tables.

o In the Referential integrity constraints, if a foreign key in Table 1 refers to the


Primary Key of Table 2, then every value of the Foreign Key in Table 1 must be
null or be available in Table 2.

Example:
4. Key constraints

o Keys are the entity set that is used to identify an entity within its entity set
uniquely.
o An entity set can have multiple keys, but out of which one key will be the
primary key. A primary key can contain a unique and null value in the relational
table.

Example:

You might also like