DBMS Unit 1 Mca 201 RGPV
DBMS Unit 1 Mca 201 RGPV
What is a DBMS?
A DBMS is a system that allows users to create, modify, and query
databases while ensuring data integrity, security, and efficient data
access. Unlike traditional file systems, DBMS minimizes data
redundancy, prevents inconsistencies, and simplifies data
management with features like concurrent access and backup
mechanisms. It organizes data into tables, views, schemas, and
reports, providing a structured approach to data management.
Example:
A university database can store and manage student information,
faculty records, and administrative data, allowing seamless retrieval,
insertion, and deletion of information as required.
Types of DBMS
There are several types of Database Management Systems (DBMS),
each tailored to different data structures, scalability requirements, and
application needs. The most common types are as follows:
2. NoSQL DBMS
NoSQL systems are designed to handle large-scale data and provide
high performance for scenarios where relational models might be
restrictive. They store data in various non-relational formats, such as
key-value pairs, documents, graphs, or columns. These flexible
data models enable rapid scaling and are well-suited for unstructured
or semi-structured data.
Examples: MongoDB, Cassandra, DynamoDB and Redis.
DDL is the short name for Data Definition Language, which deals with
database schemas and descriptions, of how the data should reside in
the database.
● CREATE: to create a database and its objects like (table,
INSERT).
● REVOKE: Removes previously granted permissions from a
user.
When the same data exists in multiple places, any update must be
manually repeated everywhere. For instance, if a student changes
their phone number, it must be updated across all sections. Failure to
do so leads to unnecessary duplication and wasted storage.
2. Inconsistency of Data
A user should know the exact location of the file to access data, so the
process is very cumbersome and tedious. If the user wants to search
the student hostel allotment number of a student from 10000 unsorted
students’ records, how difficult it can be.
4. Lack of Security
File systems provided limited control over who could access certain
data. A student who gained access to a file with grades might easily
alter it without proper authorization, compromising data integrity.
5. No Concurrent Access
File systems were not designed for multiple users working at the same
time. If one user was editing a file, others had to wait, which hindered
collaboration and slowed down workflows.
6. No Backup and Recovery
Disadvantages of DBMS
1. Complexity: DBMS can be complex to set up and maintain,
Applications of DBMS
1. Enterprise Information: Sales, accounting, human
This is the lowest level of data abstraction. It tells us how the data is actually
stored in memory. Access methods like sequential or random access and file
organization methods like B+ trees and hashing are used for the same.
Usability, size of memory, and the number of times the records are factors that
we need to know while designing the database.
Suppose we need to store the details of an employee. Blocks of storage and
the amount of memory used for these purposes are kept hidden from the user.
This level comprises the information that is actually stored in the database in
the form of tables. It also stores the relationship among the data entities in
relatively simple structures. At this level, the information available to the user at
the view level is unknown.
We can store the various attributes of an employee and relationships, e.g. with
the manager can also be stored.
The logical level thus describes the entire database in terms of a small
number of relatively simple structures. Although implementation of the simple
structures at the logical level may involve complex physical-level structures,
the user of the logical level does not need to be aware of this complexity. This
is referred to as physical data independence. Database administrators, who
must decide what information to keep in the database, use the logical level of
abstraction.
This is the highest level of abstraction. Only a part of the actual database is
viewed by the users. This level exists to ease the accessibility of the database
by an individual user. Users view data in the form of rows and columns. Tables
and relations are used to store data. Multiple views of the same database may
exist. Users can just view the data and interact with the database, storage and
implementation details are hidden from them. Even though the logical level uses
simpler structures, complexity remains because of the variety of information
stored in a large database. Many users of the database system do not need all
this information; instead, they need to access only a part of the database. The
view level of abstraction exists to simplify their interaction with the system
Data Abstraction
There may or may not be a need Whenever the logical structure of the
for changes to be made at the database has to be changed, the
internal level to improve the changes made at the logical level are
structure. important.
Example- change in
compression technology, Example – adding/modifying or
hashing algorithm, storage deleting a new attribute.
device etc.
Database Schemas
What is Schema?
A schema is the blueprint or structure that defines how data is organized and
stored in a database. It outlines the tables, fields, relationships, views, indexes,
and other elements within the database. The schema defines the logical view
of the entire database and specifies the rules that govern the data, including its
types, constraints, and relationships.
Database Schema
A database schema is the design or structure of a database that defines how
data is organized and how different data elements relate to each other. It acts
as a blueprint, outlining tables, fields, relationships, and rules that govern the
data.
and relationships.
foreign keys.
maintained.
In simple terms, the schema provides the framework that makes it easier to
these tables are connected. The logical schema ensures that the
integrity.
database. But different databases have different meanings for this. Below
2. SQL Server: In SQL Server, we use the “CREATE SCHEMA” statement for
with each database user. The statement “CREATE SCHEMA” does not create
a schema, instead, it populates the schema with tables & views and also
allows one to access those objects without needing multiple SQL statements
suited schema design for creating our database because ineffective schema
designs are difficult to manage & consume extra memory and resources.
have some effective schema designs to create our applications, let’s take a look
1. Flat Model
2. Hierarchical Model
3. Network Model
4. Relational Model
5. Star Schema
6. Snowflake Schema
Flat Model
A flat model schema is a 2-D array in which every column contains the same
type of data/information and the elements with rows are related to each other.
data using nodes (entities) and edges (relationships). However, unlike the
flexibility means that a node can have multiple parent nodes and child nodes,
The network model can contain cycles which is a situation where a path exists
that allows you to start and end at the same node. These cycles enable more
is stored as relations of the table. This relational model schema is better for
object-oriented programming.
Star Schema
Star schema is better for storing and analyzing large amounts of data. It has a
fact table at its center & multiple dimension tables connected to it just like a
star, where the fact table contains the numerical data that run business
processes and the dimension table contains data related to dimensions such
as product, time, people, etc. or we can say, this table contains the description
of the fact table. The star schema allows us to structure the data of RDBMS.
Snowflake Schema
Just like star schema, the snowflake schema also has a fact table at its center
and multiple dimension tables connected to it, but the main difference in both
models is that in snowflake schema – dimension tables are further normalized
into multiple related tables. The snowflake schema is used for analyzing large
amounts of data.
Difference between Logical and Physical Database
Schema
tables.
Database Instance
A database instance is a snapshot of a database at a specific moment in time,
containing all the properties described by a database schema as data values.
Unlike database schemas, which are considered the “blueprint” of a database,
instances can change over time whereas it is very difficult to modify the
schema because the schema represents the fundamental structure of the
database. Database instance does not hold any information related to the
saved data in database.
Hierarchical Model
This concept uses a hierarchical tree structure to organise the data. The hierarchy
begins at the root, which contains root data, and then grows into a tree as child nodes
are added to the parent node. If you wish to learn more about the hierarchical model,
click here.
Network Model
The main difference between this model and the hierarchical model is that any record
can have several parents in the network model. It uses a graph instead of a hierarchical
tree. If you wish to learn more about the network model, click here.
Entity-Relationship Model
The real-world problem is depicted in visual form in this model to make it easier for
stakeholders to comprehend. The ER diagram also makes it very simple for developers
to comprehend the system. If you wish to learn more about the entity-relationship
model, click here.
Relational Model
The data in this model is kept in the form of a table that is two-dimensional. All of the
data is kept in the form of rows and columns. Tables are the foundation of a relational
paradigm. If you wish to learn more about the relational model, click here.
Both the data and the relationship are contained in a single structure that is known as
an object in this model. We can now store audio, video, pictures, and other types of
data in databases, which was previously impossible with the relational approach
(Although you can store video and audio in relational DB, it is advised not to store them
in the relational database). If you wish to learn more about the object-oriented data
model, click here.
It’s a straightforward model in which the DB is depicted as a table with rows and
columns. If you wish to learn more about the flat data model, click here.
The relational model has evolved into the semi-structured model. In this model, we can’t
tell the difference between data and schema. If you wish to learn more about the semi-
structured data model, click here.
It is a model in which the data is separated into two sections. Everything that has its
own existence is referred to as an entity, and the relationships between these entities
are referred to as associations. Items and links are two types of data that are separated
into two components. If you wish to learn more about the associative data model, click
here.
A data model in DBMS is a set of concepts and rules that are used to
Different data models are used to represent different types of data and
disadvantages.
relationship.
and course).
Advantages or Benefits of Data Models:
Data models are essential in database design and management for
several reasons:
Data in DBMS:
Data in a DBMS refers to the raw facts and figures that are processed
Data Models
Example: Consider a university database system. Data could include
student names, IDs, courses taken, grades, and faculty details. Each
system.
1. Hierarchical Model:
data. For example- one department can have many courses, teachers
and students.
2. Network Model:
nodes.
relationships.
model in DBMS.
Suppose we are designing the network model for the Students
database. As we can see that the Subject entity has a relationship with
The Subject entity has two parents and the other two entities have one
child entity.
3. Relational Model:
attributes of an entity and the rows (or tuples) represents the records.
keys.
Any given row of the relation indicates a student i.e., the row of the
The columns of the table indicate the attributes related to the entity.
In this case, the roll number, CGPA, and the name of the student.
“follows”, etc.
“category of”.
relationship diagram
The diagram showcases two entities — Student and Course, and their
student can opt for more than one course. Student entity possesses
5. Object-Oriented Model:
data model that more closely represented the real world. In the object
oriented data model (OODM), both data and their relationships are
6. Document Model:
Documents are the most common way for storing, retrieving, and
tables.
Transaction Management
Transactions are a set of operations used to perform a logical set of work. A
transaction usually means that the data in the database has changed. One of
the major uses of DBMS is to protect the user data from system failures. It is
done by ensuring that all the data is restored to a consistent state when the
computer is restarted after a crash. The transaction is any one execution of the
user program in a DBMS. One of the important properties of the transaction is
that it contains a finite number of steps. Executing the same program multiple
times will generate multiple transactions.
1. Transaction Start.
2. Insert your ATM card.
3. Select a language for your transaction.
4. Select the Savings Account option.
5. Enter the amount you want to withdraw.
6. Enter your secret pin.
7. Wait for some time for processing.
8. Collect your Cash.
9. Transaction Completed.
Stages of Transaction
All instructions before committing come under a partially committed state and
are stored in RAM. When the commit is read the data is fully accepted and is
stored on a Hard Disk.
If the transaction is failed anywhere before committing we have to go back
and start from the beginning. We can’t continue from the same state. This is
known as Roll Back.
● A – Atomicity
● C – Consistency
● I – Isolation
● D – Durability
Transaction States
The transaction has four properties. These are used to maintain consistency in
a database, before and after the transaction.
Property of Transaction:
● Atomicity
● Consistency
● Isolation
● Durability
Atomicity
● States that all operations of the transaction take place at once if not,
the transactions are aborted.
● There is no midway, i.e., the transaction cannot occur partially. Each
transaction is treated as one unit and either run to completion or is
not executed at all.
● Atomicity involves the following two operations:
● Abort: If a transaction stops or fails, none of the changes it made will
be saved or visible.
● Commit: If a transaction completes successfully, all the changes it
made will be saved and visible.
Consistency
● The rules (integrity constraint) that keep the database accurate and
consistent are followed before and after a transaction.
● When a transaction is completed, it leaves the database either as it
was before or in a new stable state.
● This property means every transaction works with a reliable and
consistent version of the database.
● The transaction is used to transform the database from one
consistent state to another consistent state. A transaction changes
the database from one consistent state to another consistent state.
Isolation
Durability
Shadow copy
Some other transaction may also have used value produced by the failed
transaction. So we also have to rollback those transactions. The SQL standard
defines four isolation levels:
Failure Classification
To find that where the problem has occurred, we generalize a failure into the
following categories:
● Transaction failure
● System crash
● Disk failure
1. Transaction failure
The transaction failure occurs when it fails to execute or when it reaches a point
from where it can’t go any further. If a few transactions or process is hurt, then
this is called as transaction failure.
2. System Crash
System failure can occur due to power failure or other hardware or software
failure. Example: Operating system error.
3. Disk Failure
Serializability
1. Conflict Serializability
2. View Serializability
Schedule
It is of two types:
1. Serial Schedule
2. Non-Serial Schedule
Conclusion
Database Users
The people who use the system are called users. Users can be categorized into those who actually
use and manage the material (referred to as "Actors on the Scene") and those who make it
possible to create the database and the DBMS software (referred to as "Workers Behind the
Scene").
Users are put into different groups based on how they want to use the system. There are four
different kinds of database users:
1. Naive Users:
Naive users are people who don't know much about computers and use the system by
calling up one of the application programs that have already been written. For example, a
bank teller uses a program called "initaite_transfer" to move Rs. 15,000 from account A to
account B. This program asks the teller for the amount of money that needs to be moved,
the account that the money is coming from, and the account that the money is going to.
2. Application programmers:
These are people who work in computers and write programs for applications. Application
programmers have a lot of tools to choose from when making user interfaces. E.g., RAD
(Rapid Application Development) tools let an application programmer make forms and
reports without having to write a program.
3. Sophisticated users:
These people know how to use the system without writing programs. They write their
requests in a language for talking to databases. They send each query to a query
processor, whose job is to turn DML statements into instructions that the storage
manager can understand. This group is made up of analysts who use queries to look at
data in the database.
For example, Online Analytical Processing (OLAP) tools make analysts' jobs easier by
letting them see data summaries in different ways. For example, analysts can see total
products by categories, by no. of sales, or by a combination of categories and no. of
sales.
4. Specialized users:
Specialized users are advanced users who write database programs that don't fit into the
traditional way of processing data. Among these applications are computer-aided design
systems, knowledge base and expert systems, systems that store data with complex data
types (like audio/visual data), and systems that model the environment.
Database Administrators
One of the main reasons to use DBMS is to have centralized control over both the data and the
programs that access the data. The person in charge of the system as a whole is termed the
database administrator (DBA). The following are some of the duties of the DBA:
1. Defining Schema:
The DBA makes the original database schema by writing a set of definitions. The DDL
compiler translates these definitions into a set of tables, which are then stored in the data
dictionary.
2. Defining Storage Structure and Access Methods:
The DBA makes the right storage structures and access methods by writing a set of
definitions that the data-storage and data-definition language compiler translates.
3. Modification of Schema and Physical Organization:
The DBA makes changes to the schema and physical organization to reflect how the
organization's needs change or to change the physical organization to make it run better.
4. Giving Permission to Access Data:
The database administrator can control which parts of the database different users can
access by giving different types of permission. The information about who has permission
to access the data is kept in a special system structure that is checked by the database
system every time someone tries to access the data.
5. Fulfilling Integrity-Constraint Requirements:
The values of the data stored in the database must meet certain consistency
requirements. The database administrator must tell the database about this constraint.
The integrity constraints are kept in a special structure that the database system checks
every time it makes a change.
6. Regular Maintenance Tasks:
DBA regularly needs to back up the database, either to tapes or to other servers, in order
to avoid data loss in the event of emergencies. They also need to ensure that there is
sufficient free disk space for standard operations and need to update disk space as
necessary. DBA should also monitor database jobs to make sure performance is not
harmed by extremely expensive tasks supplied by some users.
As you can guess from the word "dictionary", which means a group of words, so in the
same way, a data dictionary is a group of names, attributes, and definitions of data
elements being used in a database. The data dictionary stores information like what is
in the database, who is allowed to use it etc.
Why Use a Data Dictionary?
Sample Example
Let's take an example of a data dictionary in DBMS. Suppose we have a table with the
name Person, which has the following attributes, PersonID, FirstName, LastName, City.
Now the data dictionary of this table will be:
As you can see in the above image, the complete detail of the table Person is present.
The columns are Field, Type, Null, Key, and Default.
Types of Data Dictionary
Each relational database contains an integrated data dictionary that is part of the
DBMS. This system catalogue is updated with the help of a relational database.
This integrated data dictionary is divided into two more sub-parts:
Stand Alone data dictionary is a type of dictionary that permits the admin to manage all
the required data. The list of some common elements is as follows:
● Tables
● Index
● Programs
● Data elements
● Relation between data elements
● The data directory is essential to have the proper knowledge of the content,
as the data provided by the data models are insufficient or offer fewer
details.
● Identify Data Elements: Begin by identifying all the data elements within
your dataset or database. These can include fields, columns, tables, or any
other relevant units of data.
● Document Data Attributes: For each data element, document its attributes
such as name, description, data type, length, format, and any constraints or
validations applied to it.
● Define Relationships: If your dataset contains multiple tables or entities,
define the relationships between them. Document how different data
elements relate to each other, whether through foreign keys, primary keys,
or other linkages.
● Document Business Rules: Record any business rules or logic that govern
the use and interpretation of the data. This can include data validation rules,
calculations, transformations, and any other business-specific guidelines.
● Include Metadata: Incorporate metadata such as creation date, last updated
timestamp, owner information, and any other relevant administrative details.
● Organize and Format: Organize the data dictionary in a clear and intuitive
manner, making it easy to navigate and reference. You can use tables,
diagrams, or other visual aids to enhance readability.
● Review and Validate: Review the data dictionary thoroughly to ensure
accuracy and completeness. Validate the information with stakeholders,
subject matter experts, and other relevant parties to verify its correctness.
● Maintain Documentation: Data dictionaries are living documents that
should be updated regularly to reflect any changes or additions to the data
structure. Establish a process for ongoing maintenance and version control.
There are many notations that help the user to create the Data dictionary. Let's discuss
them.
● The next notation is "+". It is used to denote the Sequence and stands for
"AND".
● Selection is the next notation denoted by "[ | ]". It stands for "OR".
● The next data construct is Parentheses, denoted by "()". It is used to
represent optional data.
● The last notation is Comment, denoted by "*…*" and stands for "to define a
comment".
There are many challenges with the Data dictionary. Let's discuss them.
● Data dictionaries become outdated very quickly if the data in the database
keeps on changing frequently.|
● Data dictionaries are difficult to use, especially for users who are not familiar
with them.
● Data dictionaries may contain some sensitive information about the data,
and if it is not properly secured, can be accessed by unauthorized users.
● It helps the user to maintain data integrity even if they are working on
multiple projects.
● It helps the user to read the structure of system requirement needs easily.
● The non-tech user might face difficulties while using the data dictionary for
the first time.
● Most of the time, relational diagrams of the data dictionary do not look
visually appealing.
Databases
Data is generated with every digital activity on a daily basis. A database is a system for
storing, managing, and retrieving data. It organises information in a way that makes it
easy to access and use for various applications. For this article, we need to understand
Centralised Databases
In a centralised database, all data is stored in a single location, such as a server. Users
can access this database through a network. Because everything is in one place,
centralised databases are easier to manage and secure. However, if the server fails, the
entire system may stop working. One example is a bank storing all of its customer data
on a central server.
Decentralised Databases
A decentralised database stores data across multiple locations or servers. Each server
holds part of the data and works independently. This system is more reliable because
even if one server fails, others continue to function. However, managing decentralised
databases can be more complex. A good example is a blockchain network where data
that manage and maintain databases efficiently. One widely used approach is the
client-server architecture, where client and server components are separated to
At the heart of any database system structure are several essential components:
Disk Storage
Disk storage is a critical component of a database management system (DBMS). It
stores data permanently, ensuring it's accessible even after a system shutdown.
Efficient use of disk storage is key to managing, retrieving, and organising large
1. Data Files: Data files hold the actual user data in a structured format. These files
store all the records, transactions, and information required by the application.
They are designed for optimised storage and fast retrieval.
2. Data Dictionary: The data dictionary is also known as metadata storage and
contains detailed information about the database structure. It records table
names, column types, constraints, and relationships. This acts as a reference for
the DBMS so it can understand how data is organised and used.
3. Indices: Indices are like shortcuts for data access. They create pointers for
specific rows or records, which enables the DBMS to locate data quickly without
scanning the entire database. Indices are necessary to greatly improve query
performance and are especially needed for large datasets.
Query Processor
The query processor is an important component of a DBMS. It interprets user queries
and executes them precisely. The query process involves several specialised
components that handle different tasks to convert high-level queries into low-level
instructions.
Storage Manager
The storage manager is an essential part of a database management system. It handles
how data is stored, retrieved, and managed on physical storage devices like disks. The
storage manager is responsible for data integrity, security, and efficient access. It
1. Authorisation Manager: It’s a check that only lets authorised users access or
modify the database. It verifies user credentials and permissions to prevent
unauthorised access, so the database is secure.
2. Integrity Manager: The integrity manager enforces rules that maintain the
correctness of the data. For example, it ensures no duplicate primary keys exist
and that foreign key constraints are followed. This prevents invalid or inconsistent
data from entering the database.
3. Transaction Manager: oversees all database transactions. It oversees that each
transaction is completed fully or not at all which is needed for maintaining the
database's reliability. This includes handling operations like rollbacks in case of
failures and maintaining data consistency.
4. File Manager: The file manager organises and manages data on physical
storage devices. It handles how data files are created, read, and written. This
component is necessary for efficient storage utilisation and supports large-scale
data management.
5. Buffer Manager: The buffer manager controls the flow of data between main
memory (RAM) and disk storage. It stores frequently accessed data temporarily
in memory to speed up data retrieval and reduce disk access time.
Concurrency control
Concurrency control enables multiple users to access a database at the same time
without causing errors or data issues. It prevents problems like data loss,
transaction, which is a single logical unit of work that retrieves or modifies data can
cause delays if executed one at a time. This increases the waiting time for other
transactions and slows overall performance. To improve throughput and reduce delays,
transactions are executed concurrently. It allows the database to handle multiple tasks
efficiently.
harmony to ensure seamless user interactions, secure data access, and efficient
database operations.
Levels of DBMS Architecture
A Database Management System (DBMS) is organised into three main levels: the
1. Internal Level
This level handles the physical storage of data within the database. It focuses on
how data is stored and retrieved from storage devices, such as hard drives or
solid-state drives. The internal level is responsible for low-level operations like
data compression, indexing, and managing storage allocation.
2. Conceptual Level:
The conceptual level represents the logical organisation of the data. It defines the
structure and relationships between data elements, including tables, attributes,
and their links. This level is independent of any specific DBMS and ensures that
the data schema can be used across different systems without affecting the
underlying database implementation.
3. External Level:
This level represents how users interact with the database. It defines the user’s
view of the data and presents it in a way that is meaningful to them. Users can
access the database through customised views or interfaces that focus on their
specific needs. They can do all this without being concerned about the
database's internal structure or logic.
involves how data is organised, stored, managed, and accessed within the system. The
important elements of the architecture of database are data models, components like
the DBMS, and how different layers, such as the storage manager, query processor,
On the other hand, tier architecture refers to the way a database system is structured.
This structure is defined by how its components are distributed across different layers.
In tier architecture, the database is divided into multiple layers, such as single-tier, two-
tier, or three-tier systems. These tiers create separation of the user interface,
The main difference to remember between the architecture of database and tier is that
database architecture focuses on the structure and components of the database system
itself. The tiered architecture deals with how these components are distributed across
different layers.
abstraction to ensure efficient functioning. These layers help define the structure and
operation of the DBMS architecture.
Since users and applications do not always interact directly with the database, various
architectures of a database system are used based on how users are connected.
independent layers:
● 1-tier architecture in DBMS has a single layer where the database and user
interface coexist.
● Two-tier DBMS architecture separates the system into two layers, typically a
client and a server.
● Three-tier architecture introduces a middle layer, such as an application server,
for additional processing.
As the number of layers increases, the level of abstraction also increases, enhancing
security and adding complexity to the database system structure. Each layer in the
one layer do not affect the others, ensuring flexibility and maintainability in the system
The user interacts with the DBMS architecture directly, making changes that
immediately reflect on the database. This architecture does not offer user-friendly tools
for end-users and is ideal for local application development where programmers need
This type of architecture of a database system is best suited for scenarios where:
Example:
When learning Structured Query Language (SQL), developers often install an SQL
server and set up a database on their local machine. This allows direct execution of
SQL queries without a network connection. This setup is a 1-tier architecture in
DBMS.
side applications directly communicate with the server-side database using APIs like
ODBC (Open Database Connectivity) or JDBC (Java Database Connectivity). The user
interface and application logic run on the client side, while the server handles tasks like
query processing and transaction management. In this DBMS architecture, the client
API Call
APIs in the architecture of database act as intermediaries which allow the client to
send requests to the server for tasks like getting, updating, or removing data. They
convert simple commands from the client into instructions the database can understand.
API makes it easy to work with different databases through standardisation and also
keeps the connection secure by including features for authentication and encryption.
Example:
Imagine withdrawing cash at a bank. The banker enters your account details and
withdrawal amount into the system. The client application (banker’s interface) sends a
request to the server-side database to check your balance and process the transaction.
known as the application server. The client does not directly communicate with the
database. Instead, client-side applications interact with the application server, which
then communicates with the database server. This layer of separation ensures that the
end-user is unaware of the database's internal details, and the database remains
processes requests from the client, then performs necessary business logic, and finally
sends the appropriate queries to the database. This separation keeps the client only
with the application layer, and hence, it keeps the database secure and independent
Consider an online shopping platform like Amazon. When a user places an order, the
client-side interface (website or app) sends the request to an application server. The
application server processes the order, verifies stock availability, and updates the
database accordingly. The client never communicates directly with the database; the
1. Scalability: The application server can manage load balancing, allowing support
for numerous clients without impacting database performance.
2. Data Integrity: The application layer filters and validates client requests,
reducing the risk of data corruption or erroneous queries.
3. Security: By removing direct access to the database, the architecture minimises
the chance of unauthorised access and enhances security.
Structure of Database Management System
A Database Management System (DBMS) is software that allows users to
define, store, maintain, and manage data in a structured and efficient manner.
of data processing by providing tools to organize data, ensure its integrity, and
They not only store and manage large amounts of data, but also provide
It also allows access to data stored in a database and provides an easy and
theft.
unauthorized persons.
has the threat of data theft; it is now a primary priority concern with serious
access to information.
enable intrusion.
ransom is paid.
Data theft prevention is not only an issue in sensitive information matters but
also for building trust between businesses and clients. Controls over access,
are effective measures one could consider to reduce the risk. Also, following
architecture of Database.
Query Processor, Storage Manager, and Disk Storage. These are explained as
following below.
Architecture of DBMS
1. Query Processor
It interprets the requests (queries) received from end user via an application
program into instructions. It also executes the user request which is received
from the DML compiler. Query Processor contains the following components
–
● DML Compiler: It processes the DML statements into low level
if a query involves joining two large tables, the optimizer will select
2. Storage Manager
Storage Manager is an interface between the data stored in the database and
the consistency and integrity of the database by applying the constraints and
database is modified.
● File Manager: It manages the file space and the data structure used
3. Disk Storage
three main components: the Internal Level, the Conceptual Level, and the
External Level.
1. Internal Level
responsible for storing and retrieving data from the storage devices, such as
2. Conceptual Level
This level represents the logical view of the database. It deals with the overall
defines the data schema, which includes tables, attributes, and their
This level represents the user’s view of the database. It deals with how users
access the data in the database. It allows users to view data in a way that
details. The external level provides a set of views or interfaces to the database,
The three levels are connected via schema mapping, ensuring that changes at
one level (e.g., the conceptual level) are accurately reflected in the others. This
Introduction of ER Model
The Entity Relationship Model is a model for identifying entities (like student,
those entities are related. The ER data model specifies enterprise schema that
application.
DBMS used.
ER Model is used to model the logical view of the system from a data
Components of ER Diagram
a Database System.
Components of ER Diagram
What is an Entity
entity that belongs to the entity type “Student,” and the group of all students
forms the entity set. In the ER diagram below, the entity type is represented
as:
Entity Set
We can represent the entity set in ER Diagram but can’t represent entity in ER
Diagram because entity is row and column in the relation and ER Diagram is
1. Strong Entity
A Strong Entity is a type of entity that has a key Attribute. Strong Entity does
not depend on other Entity in the Schema. It has a primary key, that helps in
2. Weak Entity
An Entity type has a key attribute that uniquely identifies each entity in the
entity set. But some entity type exists for which key attributes can’t be defined.
Children, Spouse) of an Employee. But the dependents can’t exist without the
identifying entity type for dependent, which means it is Strong Entity Type.
weak entity types is always total. The relationship between the weak entity
type and its identifying strong entity type is called identifying relationship and
Attributes are the properties that define the entity type. For example, Roll_No,
Name, DOB, Age, Address, and Mobile_No are the attributes that define entity
Attribute
Types of Attributes
1. Key Attribute
The attribute which uniquely identifies each entity in the entity set is called
the key attribute. For example, Roll_No will be unique for each student. In ER
Key Attribute
2. Composite Attribute
attribute. For example, the Address attribute of the student Entity type
Composite Attribute
3. Multivalued Attribute
An attribute consisting of more than one value for a given entity. For example,
Multivalued Attribute
4. Derived Attribute
An attribute that can be derived from other attributes of the entity type is
Derived Attribute
The Complete Entity Type Student with its Attributes can be represented as:
Entity and Attributes
example, ‘Enrolled in’ is a relationship type that exists between entity type
Relationship Set
Binary Relationship
What is Cardinality
The maximum number of times an entity of an entity set participates in a
1. One-to-One: When each entity in each entity set can take part only once in
the relationship, the cardinality is one-to-one. Let us assume that a male can
marry one female and a female can marry one male. So the relationship will
be one-to-one.
related to more than one entity. Let us assume that one surgeon department
3. Many-to-One: When entities in one entity set can take part only once in the
relationship set and entities in other entity sets can take part more than once
in the relationship set, cardinality is many to one. Let us assume that a student
can take only one course but one course can be taken by many students. So
the cardinality will be n to 1. It means that for one course there can be n
students but for one student, there will be only one course.
In this case, each student is taking only 1 course but 1 course has been taken
by many students.
4. Many-to-Many: When entities in all entity sets can take part more than once
can take more than one course and one course can be taken by many students.
Participation Constraint
Participation Constraint is applied to the entity participating in the relationship
set.
1. Total Participation: Each entity in the entity set must participate in the
diagram.
2. Partial Participation: The entity in the entity set may or may NOT participate
in the relationship. If some courses are not enrolled by any of the students, the
The diagram depicts the ‘Enrolled in’ relationship set with Student Entity set
having total participation and Course Entity set having partial participation.
Every student in the Student Entity set participates in a relationship but there
● Attach attributes to the entities by using ovals. Each entity can have
● Assign primary keys to each entity. These are unique identifiers that
underlined attributes.
● Remove any unnecessary or repetitive entities and relationships
● Review the diagram make sure it is clear and effectively conveys the
Here are some of the issues that can occur while ER diagram design process:
Now if we compare the two cases we discussed above, in the first case we can
say that the student can have only one student id, however in the second case
when we chose student id as an entity it implied that a student can have more
than one student id.
Let’s take an example to understand it better: A person takes a loan from a bank,
here we have two entities person and bank and their relationship is loan. This is
fine until there is a need to disburse a joint loan, in such case a new relationship
needs to be created to define the relationship between the two individuals who
have taken joint loan. In this scenario, it is better to choose loan as an entity set
rather than a relationship set.
The n-ary relationships can make ER design complex, however the good news is
that we can convert and represent any n-ary relationship using multiple binary
relationships.
This may sound confusing so lets take an example to understand how we can
convert an n-ary relationship to multiple binary relationships. Now lets say we
have to describe a relationship between four family members: father, mother, son
and daughter. This can easily be represented in forms of multiple binary
relationships, father-mother relationship as “spouse”, son and daughter
relationship as “siblings” and father and mother relationship with their child as
“child”.
how entities (tables) interact and relate to each other, establishing crucial
one entity that can link to instances of another, they enable the design of
provide the number of instances of one entity that can be linked to the
exact links between tables, preserving data integrity, and simulating actual
relationship paradigm.
Whenever an attribute of one entity type refers to another entity type, then
Example:
Example of Mapping Cardinalities
relationships.
Relationship
box.
more entities interact with each other. These relationships are often
where the customer and the product are two entities, and the act of buying
a customer buys a product. Thus, relationships can have their own unique
Example:
Example of Relationship in DBMS
‘Buys’.
as
Example
By interpreting this, we can understand that many customers can buy the
same type of product and many products can be bought by many customers.
And there are some products which are not bought by any customer and
It can be represented as
and product.
Example:
and (d1,d2, d3 ….) are the instances of entity type department and (r1, r2,
association includes exactly one entity from each participating entity type.
user to a designer.
There are two types of participation constraints, which are total and partial.
Example:
(works_for) is partial.
All possible cardinality ratios for binary relationships are explained below
with an example.
Example:
arrow which means the entity Customer is participating in the relation “has
one driving license and every driving license is associated with exactly one
customer.
ER diagram
There may be customers who do not have a credit card, but every credit
card is associated with exactly one customer. Therefore, the entity customer
Example:
one to many relationship
This relationship is one to many because “There are some employees who
manage more than one team while there is only one manager to manage a
team”.
ER diagram
Example:
Many to one realtionship
perspective.
Any number of credit cards can belong to a customer and there might be
some customers who do not have any credit card, but every credit card in a
ER diagram
4. Many to many relationship (M:N)
Example:
A customer can buy any number of products and a product can be bought
by many customers.
ER diagram
Any of the four cardinalities of a binary relationship can have both sides
partial, both total, and one partial, and one total participation, depending
Using the ER model for bigger data creates a lot of complexity while
example.
Generalization
Specialization
Vehicle.
entities.
Example of Relation
Aggregation
aid in understanding.
linkages between tables or entities, much like inheritance helps create links
between classes in object-oriented programming. It explains the process by
which a newly created table, often known as a child table, can inherit
Key Terminologies
1. Strong Entities:
2. Weak Entities:
3. Relationships:
One-to-one:
The foreign key of one entity can be added to the table of the other entity. If
both have total participation (every instance of one entity is related to an
instance of the other), foreign keys in both tables can be made non-null.
One-to-many:
The foreign key of the "one" entity is added to the table of the "many" entity.
Many-to-many:
A separate table is created to represent the relationship. This table will
include foreign keys referencing the primary keys of both entities involved in
the relationship.
Multivalued attributes:
Create a separate table for each multivalued attribute, with a foreign key
referencing the primary key of the entity to which the multivalued attribute
belongs.
4. Additional Considerations: