0% found this document useful (0 votes)
9 views31 pages

U-1 DBMS

The document provides an overview of Database Management Systems (DBMS), explaining what databases are, their characteristics, advantages, and disadvantages. It discusses various types of databases, including centralized, distributed, relational, NoSQL, and cloud databases, along with their properties and use cases. Additionally, it contrasts the DBMS approach with traditional file systems, highlighting the benefits of using a DBMS for data management.

Uploaded by

Deepak Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views31 pages

U-1 DBMS

The document provides an overview of Database Management Systems (DBMS), explaining what databases are, their characteristics, advantages, and disadvantages. It discusses various types of databases, including centralized, distributed, relational, NoSQL, and cloud databases, along with their properties and use cases. Additionally, it contrasts the DBMS approach with traditional file systems, highlighting the benefits of using a DBMS for data management.

Uploaded by

Deepak Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Database Management System (KCS501)

Unit-I
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.

or 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.

Database Management System

o Database management system is a software which is used to manage the database. For example: MySQL, Oracle

, etc are a very popular commercial database which is used in different applications.
o DBMS provides an interface to perform various operations like database creation, storing data in it, updating data,
creating a table in the database and a lot more.
o It provides protection and security to the database. In the case of multiple users, it also maintains data consistency.

DBMS allows users the following tasks:

o Data Definition: It is used for creation, modification, and removal of definition that defines the organization of
data in the database.
o Data Updation: It is used for the insertion, modification, and deletion of the actual data in the database.
o Data Retrieval: It is used to retrieve the data from the database which can be used by applications for various
purposes.
o User Administration: It is used for registering and monitoring users, maintain data integrity, enforcing data
security, dealing with concurrency control, monitoring performance and recovering information corrupted by
unexpected failure.

Characteristics of DBMS

o It uses a digital repository established on a server to store and manage the information.
o It can provide a clear and logical view of the process that manipulates data.
o DBMS contains automatic backup and recovery procedures.
o It contains ACID properties which maintain data in a healthy state in case of failure.
o It can reduce the complex relationship between data.
o It is used to support manipulation and processing of data.
o It is used to provide security of data.
o It can view the database from different viewpoints according to the requirements of the user.

Advantages of DBMS

o Controls database redundancy: It can control data redundancy because it stores all the data in one single
database file and that recorded data is placed in the database.
o Data sharing: In DBMS, the authorized users of an organization can share the data among multiple users.
o Easily Maintenance: It can be easily maintainable due to the centralized nature of the database system.
o Reduce time: It reduces development time and maintenance need.
o Backup: It provides backup and recovery subsystems which create automatic backup of data from hardware and
sofware failures and restores the data if required.
o multiple user interface: It provides different types of user interfaces like graphical user interfaces, application
program interfaces

Disadvantages of DBMS

o Cost of Hardware and Software: It requires a high speed of data processor and large memory size to run DBMS
software.
o Size: It occupies a large space of disks and large memory to run them efficiently.
o Complexity: Database system creates additional complexity and requirements.
o Higher impact of failure: Failure is highly impacted the database because in most of the organization, all the
data stored in a single database and if the database is damaged due to electric failure or database corruption then
the data may be lost forever.

What is Data?
Data is a collection of a distinct small unit of information. It can be used in a variety of forms like text, numbers, media,
bytes, etc. it can be stored in pieces of paper or electronic memory, etc.

Word 'Data' is originated from the word 'datum' that means 'single piece of information.' It is plural of the word datum.

In computing, Data is information that can be translated into a form for efficient movement and processing. Data is
interchangeable.

What is Database?
A database is an organized collection of data, so that it can be easily accessed and managed.

You can organize data into tables, rows, columns, and index it to make it easier to find relevant information.

Database handlers create a database in such a way that only one set of software program provides access of data to all
the users.

The main purpose of the database is to operate a large amount of information by storing, retrieving, and managing data.

There are many dynamic websites on the World Wide Web nowadays which are handled through databases. For example,
a model that checks the availability of rooms in a hotel. It is an example of a dynamic website that uses a database.

There are many databases available like MySQL, Sybase, Oracle, MongoDB, Informix, PostgreSQL, SQL Server, etc.

Modern databases are managed by the database management system (DBMS).

SQL or Structured Query Language is used to operate on the data stored in a database. SQL depends on relational algebra
and tuple relational calculus.

A cylindrical structure is used to display the image of a database.

Concept/Types/ Bases of Database


1) Centralized Database
It is the type of database that stores data at a centralized database system. It comforts the users to access the stored data
from different locations through several applications. These applications contain the authentication process to let users
access data securely. An example of a Centralized database can be Central Library that carries a central database of each
library in a college/university.

Advantages of Centralized Database


o It has decreased the risk of data management, i.e., manipulation of data will not affect the core data.
o Data consistency is maintained as it manages data in a central repository.
o It provides better data quality, which enables organizations to establish data standards.
o It is less costly because fewer vendors are required to handle the data sets.

Disadvantages of Centralized Database


o The size of the centralized database is large, which increases the response time for fetching the data.
o It is not easy to update such an extensive database system.
o If any server failure occurs, entire data will be lost, which could be a huge loss.

2) Distributed Database
Unlike a centralized database system, in distributed systems, data is distributed among different database systems of an
organization. These database systems are connected via communication links. Such links help the end-users to access the
data easily. Examples of the Distributed database are Apache Cassandra, HBase, Ignite, etc.

We can further divide a distributed database system into:

o Homogeneous DDB: Those database systems which execute on the same operating system and use the same
application process and carry the same hardware devices.
o Heterogeneous DDB: Those database systems which execute on different operating systems under different
application procedures, and carries different hardware devices.
Advantages of Distributed Database
o Modular development is possible in a distributed database, i.e., the system can be expanded by including new
computers and connecting them to the distributed system.
o One server failure will not affect the entire data set.

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.

Properties of Relational Database

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.

4) NoSQL Database
Non-SQL/Not Only SQL is a type of database that is used for storing a wide range of data sets. It is not a relational database
as it stores data not only in tabular form but in several different ways. It came into existence when the demand for building
modern applications increased. Thus, NoSQL presented a wide variety of database technologies in response to the demands.
We can further divide a NoSQL database into the following four types:

a. Key-value storage: It is the simplest type of database storage where it stores every single item as a key (or
attribute name) holding its value, together.
b. Document-oriented Database: A type of database used to store data as JSON-like document. It helps developers
in storing data by using the same document-model format as used in the application code.
c. Graph Databases: It is used for storing vast amounts of data in a graph-like structure. Most commonly, social
networking websites use the graph database.
d. Wide-column stores: It is similar to the data represented in relational databases. Here, data is stored in large
columns together, instead of storing in rows.

Advantages of NoSQL Database


o It enables good productivity in the application development as it is not required to store data in a structured
format.
o It is a better option for managing and handling large data sets.
o It provides high scalability.
o Users can quickly access data from the database through key-value.

5) Cloud Database
A type of database where data is stored in a virtual environment and executes over the cloud computing platform. It
provides users with various cloud computing services (SaaS, PaaS, IaaS, etc.) for accessing the database. There are
numerous cloud platforms, but the best options are:

o Amazon Web Services(AWS)


o Microsoft Azure
o Kamatera
o PhonixNAP
o ScienceSoft
o Google Cloud SQL, etc.

6) Object-oriented Databases
The type of database that uses the object-based data model approach for storing data in the database system. The data is
represented and stored as objects which are similar to the objects used in the object-oriented programming language.

7) Hierarchical Databases
It is the type of database that stores data in the form of parent-children relationship nodes. Here, it organizes data in a tree-
like structure.

Data get stored in the form of records that are connected via links. Each child record in the tree will contain only one parent.
On the other hand, each parent record can have multiple child records.

8) Network Databases
It is the database that typically follows the network data model. Here, the representation of data is in the form of nodes
connected via links between them. Unlike the hierarchical database, it allows each record to have multiple children and
parent nodes to form a generalized graph structure.

9) Personal Database
Collecting and storing data on the user's system defines a Personal Database. This database is basically designed for a
single user.

Advantage of Personal Database


o It is simple and easy to handle.
o It occupies less storage space as it is small in size.

10) Operational Database


The type of database which creates and updates the database in real-time. It is basically designed for executing and
handling the daily data operations in several businesses. For example, An organization uses operational databases for
managing per day transactions.

11) Enterprise Database


Large organizations or enterprises use this database for managing a massive amount of data. It helps organizations to
increase and improve their efficiency. Such a database allows simultaneous access to users.

Advantages of Enterprise Database:


o Multi processes are supportable over the Enterprise database.
o It allows executing parallel queries on the system.

DBMS vs. File System

File System Approach


File based systems were an early attempt to computerize the manual system. It is also called a traditional based approach in
which a decentralized approach was taken where each department stored and controlled its own data with the help of a
data processing specialist. The main role of a data processing specialist was to create the necessary computer file
structures, and also manage the data within structures and design some application programs that create reports based on
file data.

In the above figure:

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.

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,

In the above figure, duplication of data is reduced due to centralization of data.

There are the following differences between DBMS and File systems:

Basis DBMS Approach File System Approach

Meaning DBMS is a collection of data. In DBMS, the user is not The file system is a collection of data. In this
required to write the procedures. system, the user has to write the procedures for
managing the database.

Sharing of data Due to the centralized approach, data sharing is easy. Data is distributed in many files, and it may be of
different formats, so it isn't easy to share data.

Data Abstraction DBMS gives an abstract view of data that hides the The file system provides the detail of the data
details. representation and storage of data.

Security and DBMS provides a good protection mechanism. It isn't easy to protect a file under the file
Protection system.

Recovery DBMS provides a crash recovery mechanism, i.e., The file system doesn't have a crash mechanism,
Mechanism DBMS protects the user from system failure. i.e., if the system crashes while entering some
data, then the content of the file will be lost.

Manipulation DBMS contains a wide variety of sophisticated The file system can't efficiently store and retrieve
Techniques techniques to store and retrieve the data. the data.

Concurrency DBMS takes care of Concurrent access of data using In the File system, concurrent access has many
Problems some form of locking. problems like redirecting the file while deleting
some information or updating some information.

Where to use Database approach used in large systems which File system approach used in large systems
interrelate many files. which interrelate many files.

Cost The database system is expensive to design. The file system approach is cheaper to design.

Data Redundancy Due to the centralization of the database, the In this, the files and application programs are
and problems of data redundancy and inconsistency are created by different programmers so that there
Inconsistency controlled. exists a lot of duplication of data which may lead
to inconsistency.

Structure The database structure is complex to design. The file system approach has a simple structure.

Data In this system, Data Independence exists, and it can In the File system approach, there exists no Data
Independence be of two types. Independence.
o Logical Data Independence
o Physical Data Independence
Integrity Integrity Constraints are easy to apply. Integrity Constraints are difficult to implement in
Constraints file system.

Data Models In the database approach, 3 types of data models In the file system approach, there is no concept
exist: of data models exists.
o Hierarchal data models
o Network data models
o Relational data models

Flexibility Changes are often a necessity to the content of the The flexibility of the system is less as compared
data stored in any system, and these changes are to the DBMS approach.
more easily with a database approach.

Examples Oracle, SQL Server, Sybase etc. Cobol, C++ etc.

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.
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.

Fig: 3-tier Architecture

Three schema(योजना)Architecture
o The three schema architecture is also called ANSI/SPARC (American National Standards Institute, Standards Planning And
Requirements Committee) 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.

Objectives of Three schema Architecture


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:

o Different users need different views of the same data.


o The approach in which a particular user needs to see the data may change over time.
o 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.
o All users should be able to access the same data according to their requirements.
o DBA should be able to change the conceptual structure of the database without affecting the user's
o Internal structure of the database should be unaffected by changes to physical aspects of the storage.

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.

The internal level is generally is concerned with the following activities:

o Storage space allocations.


For Example: B-Trees, Hashing etc.
o Access paths.
For Example: Specification of primary and secondary keys, indexes, pointers and sequencing.
o Data compression and encryption techniques.
o Optimization of internal structures.
o Representation of stored fields.

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.

Mapping between Views


The three levels of DBMS architecture don't exist independently of each other. There must be correspondence between the
three levels i.e. how they actually correspond with each other. DBMS is responsible for correspondence between the three
types of schema. This correspondence is called Mapping.

There are basically two types of mapping in the database architecture:

o Conceptual/ Internal Mapping


o External / Conceptual Mapping

Conceptual/ Internal Mapping

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.

External/ Conceptual Mapping

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.

2) Entity-Relationship Data Model: An ER model is the logical representation of data as objects and relationships among
them. These objects are known as entities, and relationship is an association among these entities. This model was designed
by Peter Chen and published in 1976 papers. It was widely used in database designing. A set of attributes describe the
entities. For example, student_name, student_id describes the 'student' entity. A set of the same type of entities is known as
an 'Entity set', and the set of the same type of relationships is known as 'relationship set'.

3) Object-based Data Model: An extension of the ER model with notions of functions, encapsulation, and object identity,
as well. This model supports a rich type system that includes structured and collection types. Thus, in 1980s, various
database systems following the object-oriented approach were developed. Here, the objects are nothing but the data
carrying its properties.

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.

Data model Schema and Instance


o The data which is stored in the database at a particular moment of time is called an instance of the database.
o The overall design of a database is called schema.
o A database schema is the skeleton structure of the database. It represents the logical view of the entire database.
o A schema contains schema objects like table, foreign key, primary key, views, columns, data types, stored
procedure, etc.
o A database schema can be represented by using the visual diagram. That diagram shows the database objects and
relationship with each other.
o A database schema is designed by the database designers to help programmers whose software will interact with
the database. The process of database creation is called data modeling.

A schema diagram can display only some aspects of a schema like the name of record type, data type, and constraints.
Other aspects can't be specified through the schema diagram. For example, the given figure neither show the data type of
each data item nor the relationship among various files.

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.

Data Independence
o Data independence can be explained using the three-schema architecture.
o Data independence refers characteristic of being able to modify the schema at one level of the database system
without altering the schema at the next higher level.

There are two types of data independence:

1. Logical Data Independence

o Logical data independence refers characteristic of being able to change the conceptual schema without having to
change the external schema.
o Logical data independence is used to separate the external level from the conceptual view.
o If we do any changes in the conceptual view of the data, then the user view of the data would not be affected.
o Logical data independence occurs at the user interface level.

2. Physical Data Independence

o Physical data independence can be defined as the capacity to change the internal schema without having to
change the conceptual schema.
o If we do any changes in the storage size of the database system server, then the Conceptual structure of the
database will not be affected.
o Physical data independence is used to separate conceptual levels from the internal levels.
o Physical data independence occurs at the logical interface level.
Fig: Data Independence

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.

Database Interfaces
A software program known as a database management system (DBMS) is used to manage, compile, and store data in a systematic
manner. The user and the database are connected through DBMS interfaces. They give users an easy-to-use interface so they may
access and change the data that is stored in the database. There are several DBMS interface types, each created to meet certain
user requirements.
The most typical kinds of DBMS interfaces are as follows −

Command-Line Interface (CLI)

The earliest and most fundamental form of DBMS interface is the command-line interface (CLI). Through the use of a command
prompt, users may communicate with the database by inputting commands. Users can only access and modify the database using
particular commands and syntax. Today, programmers and database administrators are the main users of CLI.

Graphical User Interface (GUI)

The most prevalent kind of DBMS interface used nowadays is the graphical user interface (GUI). Users may interact with the
database using the user-friendly interface's graphical menus and icons. GUIs are user-friendly and need little to no programming
experience. They are mostly utilized by non-programmers who are end users.

Web-Based Interface

Users can access the database using a browser using the web-based interface. Users can use online forms, buttons, and other
graphical components to interact with the database using a web browser. Because they can be accessed from any location with an
internet connection, web-based interfaces are common.

Natural Language Interface

This interface enables users to communicate with the database in their own language. The system will convert user inquiries into
SQL instructions and carry them out if they are entered in plain English. Users who are unfamiliar with SQL commands might benefit
from using natural language interfaces.
Forms-Based Interface

Using the forms-based interface, users may enter data into the database using a graphical user interface. Users can complete pre-
made forms that provide fields for particular categories of information, such as name, address, and phone number. Applications for
data entry frequently employ forms-based interfaces.

Menu-Based Interface

Users have access to a number of predefined menus and choices when using the menu-based interface to interact with the
database. Users can choose the menu choice that reflects the intended action, such as adding or removing data, from the available
options. The majority of specialized applications and embedded systems employ menu-based interfaces.

Users can interact with the database thanks in large part to DBMS interfaces. The user's technical proficiency, the nature of the
program, and the target market all influence the interface choice. The user experience and database usability may both be improved
by selecting the correct interface.

Overall Structure of DBMS


As we have discussed above, the structure of DBMS is divided into three main components. In this section, we will discuss each of these
components in detail.
1. Query Processor
The primary role of the Query Processor is to interpret and execute queries given by the user. When a user or an application sends a
question to the DBMS, the query manager first translates that query into a low-level language, which the storage manager understands. The
storage manager then processes the query and provides the data the user or the application requires. The Query Processor then sends this
data back to the user.
The query processor has the following components.
 DDL Compiler - DDL stands for Data Definition Language. The DDL compiler changes the DDL statements into a specific format to
make sense to the storage manager. The DDL also ensures the consistency and validity of the database.

 DML Compiler - DML stands for Data Manipulation Language. The DML compiler changes DML commands like SELECT, INSERT, and
DELETE into low-level instructions so the storage manager can understand them. The DML compiler also optimizes the queries to
guarantee faster execution.

 Embedded DML Pre-compiler - The Embedded DML pre-compiler processes the DML commands and precompiles them into standard
procedural calls, which can be executed within the host programming language.

 Query optimizer - This system component processes the SQL queries and determines the most efficient execution plan for the queries.
The query optimizer considers all the possible ways to process a query. It then chooses the most optimal route among them. The query
optimizer helps reduce the execution time and the resources required for a query. It also helps in providing a faster response to users.
2. Storage Manager
The storage manager is the part of the Database management system responsible for controlling the data storage in the database. The
storage manager's main job is to handle the secondary storage's storage. It also allows retrieval of data to offer access to the database.
The storage manager is responsible for creating, reading, updating, and deleting data in the database. It also ensures that the database
maintains its consistency and integrity by denying any unauthorized access. The storage manager's main components are listed below.
 File Manager - The file manager is responsible for creating, opening, and removing files in the database.
 Access Manager - The access manager controls user access to databases and ensures no one is given unlawful access.

 Transaction Manager - The transaction manager is responsible for ensuring the consistency of the transactions. It also checks
modifications in the database and allows recovery of data.

 Disk Space Manager - The DSM controls the allocation and deallocation of disc space and constantly informs if the space is available.

 Buffer Manager - The Buffer Manager performs memory caching to give faster access to frequently used data.
3. Disk Storage
Disk Storage refers to physical storage devices like hard disks, which are used to store data. Disk storage provides a medium for storing data
that remains stored even after the system is shut down. The Disk storage has mainly three components.
 Data Dictionary - This database component provides metadata about the data components. These components include tables, relations,
and columns with their names, descriptions, constraints, etc.

 Data Files - Data files are physical units of storage that store the data in a file systematically. These are stored on hard drives, solid-state
drives, etc.

 Indices - In a database management system, indices are a type of Data Structure to provide fast access to data based on specific
columns of a table. This help finds particular data entry rows which match the given search criteria.

The disk storage is optimized for storing data efficiently. It also ensures fast retrieval to user queries. The disk storage applies various
techniques like partitioning, caching, indexing, data compression, etc. to ensure these optimizations.

Difference between DBMS Structure and DBMS Architecture


S.No. DBMS Structure DBMS Architecture

It is the process of developing a


It refers to the entire structure
structured database plan. This
of a database system, which
includes deciding what data will
includes the hardware and
1 be stored in the database, how
software components as well as
it will be arranged, and how
how they interact with one
different data pieces will be
another.
related to one another.

2 The goal of database design is to It is concerned with the overall


create a structure that is both design of the system, including
efficient and effective in meeting the hardware and software
S.No. DBMS Structure DBMS Architecture

infrastructure, the data storage


the needs of the users of the and retrieval mechanisms, and
database. the overall system performance
and scalability.

DBMS Architecture deals with


DBMS structure Ensures data
3 communication and system
integrity through constraints.
interactions.

It Specifies permissions and It addresses scalability,


4
security features. performance, and design

It manages concurrent access


It ensures that multiple users or
through techniques like locking,
transactions can access and
5 timestamp ordering, and
modify data simultaneously
transaction isolation levels to
without conflicts.
maintain data consistency.

ER model
o ER model stands for an Entity-Relationship model. It is a high-level data model. This model is used to define the
data elements and relationship for a specified system.
o It develops a conceptual design for the database. It also develops a very simple and easy to design view of data.
o In ER modeling, the database structure is portrayed as a diagram called an entity-relationship diagram.

For example, Suppose we design a school database. In this database, the student will be an entity with attributes like
address, name, id, age, etc. The address can be another entity with attributes like city, street name, pin code, etc and there
will be a relationship between them.

Component of ER Diagram
1. Entity:

An entity may be any object, class, person or place. In the ER diagram, an entity can be represented as rectangles.

Consider an organization as an example- manager, product, employee, department etc. can be taken as an entity.

a. Weak Entity

An entity that depends on another entity called a weak entity. The weak entity doesn't contain any key attribute of its own.
The weak entity is represented by a double rectangle.

2. Attribute

The attribute is used to describe the property of an entity. Eclipse is used to represent an attribute.

For example, id, age, contact number, name, etc. can be attributes of a student.

a. Key Attribute

The key attribute is used to represent the main characteristics of an entity. It represents a primary key. The key attribute is
represented by an ellipse with the text underlined.
b. Composite Attribute

An attribute that composed of many other attributes is known as a composite attribute. The composite attribute is
represented by an ellipse, and those ellipses are connected with an ellipse.

c. Multivalued Attribute

An attribute can have more than one value. These attributes are known as a multivalued attribute. The double oval is used
to represent multivalued attribute.

For example, a student can have more than one phone number.

d. Derived Attribute

An attribute that can be derived from other attribute is known as a derived attribute. It can be represented by a dashed
ellipse.

For example, A person's age changes over time and can be derived from another attribute like Date of birth.
3. Relationship

A relationship is used to describe the relation between entities. Diamond or rhombus is used to represent the relationship.

Types of relationship are as follows:

a. One-to-One Relationship

When only one instance of an entity is associated with the relationship, then it is known as one to one relationship.

For example, A female can marry to one male, and a male can marry to one female.

b. One-to-many relationship

When only one instance of the entity on the left, and more than one instance of an entity on the right associates with the
relationship then this is known as a one-to-many relationship.

For example, Scientist can invent many inventions, but the invention is done by the only specific scientist.

c. Many-to-one relationship

When more than one instance of the entity on the left, and only one instance of an entity on the right associates with the
relationship then it is known as a many-to-one relationship.

For example, Student enrolls for only one course, but a course can have many students.

d. Many-to-many relationship

When more than one instance of the entity on the left, and more than one instance of an entity on the right associates with
the relationship then it is known as a many-to-many relationship.
For example, Employee can assign by many projects and project can have many employees.

Notation of ER diagram
Database can be represented using the notations. In ER diagram, many notations are used to express the cardinality. These
notations are as follows:

Fig: Notations of ER diagram

Mapping Constraints
o A mapping constraint is a data constraint that expresses the number of entities to which another entity can be
related via a relationship set.
o It is most useful in describing the relationship sets that involve more than two entity sets.
o For binary relationship set R on an entity set A and B, there are four possible mapping cardinalities. These are as
follows:
1. One to one (1:1)
2. One to many (1:M)
3. Many to one (M:1)
4. Many to many (M:M)

One-to-one
In one-to-one mapping, an entity in E1 is associated with at most one entity in E2, and an entity in E2 is associated with at
most one entity in E1.
One-to-many
In one-to-many mapping, an entity in E1 is associated with any number of entities in E2, and an entity in E2 is associated
with at most one entity in E1.

Many-to-one
In one-to-many mapping, an entity in E1 is associated with at most one entity in E2, and an entity in E2 is associated with
any number of entities in E1.

Many-to-many
In many-to-many mapping, an entity in E1 is associated with any number of entities in E2, and an entity in E2 is associated
with any number of entities in E1.

Keys
o Keys play an important role in the relational database.
o It is used to uniquely identify any record or row of data from the table. It is also used to establish and identify
relationships between tables.

For example, ID is used as a key in the Student table because it is unique for each student. In the PERSON table,
passport_number, license_number, SSN are keys since they are unique for each person.

Types of keys:
1. Primary key
o It is the first key used to identify one and only one instance of an entity uniquely. An entity can contain multiple
keys, as we saw in the PERSON table. The key which is most suitable from those lists becomes a primary key.
o In the EMPLOYEE table, ID can be the primary key since it is unique for each employee. In the EMPLOYEE table, we
can even select License_Number and Passport_Number as primary keys since they are also unique.
o For each entity, the primary key selection is based on requirements and developers.

2. Candidate key
o A candidate key is an attribute or set of attributes that can uniquely identify a tuple.
o Except for the primary key, the remaining attributes are considered a candidate key. The candidate keys are as
strong as the primary key.

For example: In the EMPLOYEE table, id is best suited for the primary key. The rest of the attributes, like SSN,
Passport_Number, License_Number, etc., are considered a candidate key.

3. Super Key

Super key is an attribute set that can uniquely identify a tuple. A super key is a superset of a candidate key.

For example: In the above EMPLOYEE table, for(EMPLOEE_ID, EMPLOYEE_NAME), the name of two employees can be the
same, but their EMPLYEE_ID can't be the same. Hence, this combination can also be a key.

The super key would be EMPLOYEE-ID (EMPLOYEE_ID, EMPLOYEE-NAME), etc.


4. Foreign key
o Foreign keys are the column of the table used to point to the primary key of another table.
o Every employee works in a specific department in a company, and employee and department are two different
entities. So we can't store the department's information in the employee table. That's why we link these two tables
through the primary key of one table.
o We add the primary key of the DEPARTMENT table, Department_Id, as a new attribute in the EMPLOYEE table.
o In the EMPLOYEE table, Department_Id is the foreign key, and both the tables are related.

5. Alternate key

There may be one or more attributes or a combination of attributes that uniquely identify each tuple in a relation. These
attributes or combinations of the attributes are called the candidate keys. One key is chosen as the primary key from these
candidate keys, and the remaining candidate key, if it exists, is termed the alternate key. In other words, the total number
of the alternate keys is the total number of candidate keys minus the primary key. The alternate key may or may not exist.
If there is only one candidate key in a relation, it does not have an alternate key.

For example, employee relation has two attributes, Employee_Id and PAN_No, that act as candidate keys. In this relation,
Employee_Id is chosen as the primary key, so the other candidate key, PAN_No, acts as the Alternate key.

6. Composite key

Whenever a primary key consists of more than one attribute, it is known as a composite key. This key is also known as
Concatenated Key.

For example, in employee relations, we assume that an employee may be assigned multiple roles, and an employee may
work on multiple projects simultaneously. So the primary key will be composed of all three attributes, namely Emp_ID,
Emp_role, and Proj_ID in combination. So these attributes act as a composite key since the primary key comprises more
than one attribute.
7. Artificial key

The key created using arbitrarily assigned data are known as artificial keys. These keys are created when a primary key is
large and complex and has no relationship with many other relations. The data values of the artificial keys are usually
numbered in a serial order.

For example, the primary key, which is composed of Emp_ID, Emp_role, and Proj_ID, is large in employee relations. So it
would be better to add a new virtual attribute to identify each tuple in the relation uniquely.

Generalization
o Generalization is like a bottom-up approach in which two or more entities of lower level combine to form a higher
level entity if they have some attributes in common.
o In generalization, an entity of a higher level can also combine with the entities of the lower level to form a further
higher level entity.
o Generalization is more like subclass and superclass system, but the only difference is the approach. Generalization
uses the bottom-up approach.
o In generalization, entities are combined to form a more generalized entity, i.e., subclasses are combined to make a
superclass.

For example, Faculty and Student entities can be generalized and create a higher level entity Person.

Specialization
o Specialization is a top-down approach, and it is opposite to Generalization. In specialization, one higher level entity
can be broken down into two lower level entities.
o Specialization is used to identify the subset of an entity set that shares some distinguishing characteristics.
o Normally, the superclass is defined first, the subclass and its related attributes are defined next, and relationship
set are then added.

For example: In an Employee management system, EMPLOYEE entity can be specialized as TESTER or DEVELOPER based
on what role they play in the company.
In aggregation, the relation between two entities is treated as a single entity. In aggregation, relationship with its
corresponding entities is aggregated into a higher level entity.

For example: Center entity offers the Course entity act as a single entity in the relationship which is in a relationship with
another entity visitor. In the real world, if a visitor visits a coaching center then he will never enquiry about the Course only
or just about the Center instead he will ask the enquiry about both.

Reduction of ER diagram to Table


The database can be represented using the notations, and these notations can be reduced to a collection of tables.

In the database, every entity set or relationship set can be represented in tabular form.

The ER diagram is given below:


There are some points for converting the ER diagram to the table:

o Entity type becomes a table.

In the given ER diagram, LECTURE, STUDENT, SUBJECT and COURSE forms individual tables.

o All single-valued attribute becomes a column for the table.

In the STUDENT entity, STUDENT_NAME and STUDENT_ID form the column of STUDENT table. Similarly, COURSE_NAME and
COURSE_ID form the column of COURSE table and so on.

o A key attribute of the entity type represented by the primary key.

In the given ER diagram, COURSE_ID, STUDENT_ID, SUBJECT_ID, and LECTURE_ID are the key attribute of the entity.

o The multivalued attribute is represented by a separate table.

In the student table, a hobby is a multivalued attribute. So it is not possible to represent multiple values in a single column
of STUDENT table. Hence we create a table STUD_HOBBY with column name STUDENT_ID and HOBBY. Using both the
column, we create a composite key.

o Composite attribute represented by components.

In the given ER diagram, student address is a composite attribute. It contains CITY, PIN, DOOR#, STREET, and STATE. In the
STUDENT table, these attributes can merge as an individual column.

o Derived attributes are not considered in the table.

In the STUDENT table, Age is the derived attribute. It can be calculated at any point of time by calculating the difference
between current date and Date of Birth.
Using these rules, you can convert the ER diagram to tables and columns and assign the mapping between the tables. Table
structure for the given ER diagram is as below:

Figure: Table structure

Relationship of higher degree


The degree of relationship can be defined as the number of occurrences in one entity that is associated with the number of
occurrences in another entity.

There is the three degree of relationship:

1. One-to-one (1:1)
2. One-to-many (1:M)
3. Many-to-many (M:N)

1. One-to-one
o In a one-to-one relationship, one occurrence of an entity relates to only one occurrence in another entity.
o A one-to-one relationship rarely exists in practice.
o For example: if an employee is allocated a company car then that car can only be driven by that employee.
o Therefore, employee and company car have a one-to-one relationship.

2. One-to-many
o In a one-to-many relationship, one occurrence in an entity relates to many occurrences in another entity.
o For example: An employee works in one department, but a department has many employees.
o Therefore, department and employee have a one-to-many relationship.
3. Many-to-many
o In a many-to-many relationship, many occurrences in an entity relate to many occurrences in another entity.
o Same as a one-to-one relationship, the many-to-many relationship rarely exists in practice.
o For example: At the same time, an employee can work on several projects, and a project has a team of many
employees.
o Therefore, employee and project have a many-to-many relationship.

You might also like