0% found this document useful (0 votes)
3 views10 pages

DBMS

A database is an organized electronic collection of data that allows for efficient management, retrieval, and updating of information. Its main purposes include data management, retrieval, integrity, security, and concurrent access, with applications in various sectors like healthcare, e-commerce, and banking. Key advantages of using a Database Management System (DBMS) include data redundancy control, consistency, improved data sharing, security, and efficient data access.

Uploaded by

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

DBMS

A database is an organized electronic collection of data that allows for efficient management, retrieval, and updating of information. Its main purposes include data management, retrieval, integrity, security, and concurrent access, with applications in various sectors like healthcare, e-commerce, and banking. Key advantages of using a Database Management System (DBMS) include data redundancy control, consistency, improved data sharing, security, and efficient data access.

Uploaded by

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

What is Database? main purpose of a database 3.

Healthcare and Hospital Systems


system? Use: To store patient records, appointment schedules,
A database is an organized collection of data that is billing information, and medical history.
stored and accessed electronically. It allows data to be Example: Doctors can retrieve a patient’s medical
easily stored, managed, retrieved, and updated. history instantly to make informed decisions.
Databases are managed by Database Management Key Features: Privacy, secure access, and integration
Systems (DBMS) such as MySQL, PostgreSQL, Oracle, with medical devices.
or Microsoft SQL Server. 4. E-commerce Platforms
Use: To manage product catalogs, customer data, orders,
Main Purpose of a Database System payments, and reviews.
Example: Amazon uses a database to keep track of
Ef cient Data Management: Store large volumes of millions of products, user reviews, and order history.
data in a structured format. Key Features: Scalability, fast queries, personalized
Data Retrieval: Quickly search for and retrieve speci c recommendations.
information.
Data Integrity: Ensure data accuracy and consistency What are the key advantages of using a
through constraints and rules. database management system (DBMS)?
Data Security: Control access to data and protect Data Redundancy Control
sensitive information. DBMS minimizes duplicate data by storing data in a
Concurrent Access: Allow multiple users to access and centralized location and using relationships among
work with the data simultaneously without con ict. tables.
Minimize Redundancy: Avoid duplication of data Data Consistency
through normalization. Ensures that data remains accurate and consistent across
Backup and Recovery: Ensure data is not lost and can the system, especially when multiple users access and
be restored in case of failures. modify it.
Improved Data Sharing
Multiple users can access data simultaneously, with
Enlist various Database-System appropriate access controls in place.
Applications and explain any four.
Better Data Security
Banking Systems
DBMS provides user-based access control,
Airline Reservation Systems
authentication, and authorization to protect sensitive
E-commerce and Online Retail
information.
Education Systems (Universities/Colleges)
Backup and Recovery
Telecommunication Systems
Automatic backup and recovery features protect data
Healthcare and Hospital Systems
from crashes, system failures, or accidental deletion.
Social Media Platforms
Data Integrity
Government and Public Sector Systems
Enforces rules and constraints (like primary keys and
Human Resource Management Systems (HRMS)
foreign keys) to maintain correct and valid data.
Inventory Management Systems
Ef cient Data Access
Supports powerful query languages like SQL, allowing
1. Banking Systems
users to retrieve and manipulate data quickly and
Use: To manage customer accounts, transactions, loans,
exibly.
and nancial records.
Scalability
Example: When you withdraw money from an ATM,
DBMS systems can handle increasing amounts of data
the banking database updates your account balance in
and users without a loss in performance.
real time.
Data Abstraction
Key Features: Transaction management, security, audit
Hides the complex details of how data is stored and
trail, and high availability.
managed, providing a user-friendly interface.
2. Airline Reservation Systems
Concurrency Control
Use: To manage ight schedules, bookings, ticketing,
Ensures that multiple users can access the database
and customer data.
simultaneously without con icts or data corruption.
Example: When you book a ight online, the system
updates seat availability and customer information in the
database.
Key Features: Real-time availability, booking
con rmation, multi-user access.
fl
fi
fi
fi
fi
fl
fl
fl
fl
fi
Draw and explain ER Diagram for Library System Management.

Feature Strong Entity Weak Entity

Exists independently of other


Existence Depends on a related strong entity for its existence.
entities.

Has its own unique primary


Primary Key No suf cient primary key on its own.
key.

Identi ed solely by its own


Identi cation Identi ed using a foreign key + partial key.
attributes.

May exist with or without Must have a total participation in an identifying


Relationship
relationships. relationship.

Notation (ER Represented by a single


Represented by a double rectangle.
Diagram) rectangle.

Student(Student_ID Dependent(Dep_Name, Age,


Example
, Name, Age) Relationship) (related to Employee)

Key Primary key is derived from Primary key is partially derived from a related
Constraint its own attributes. entity.
fi
fi
fi
fi
Define Functional Dependency (FD) in ACID properties
DBMS
with an example. ACID is an acronym for the four key
A Functional Dependency is a constraint that properties that ensure reliable processing of
describes a relationship between attributes in database transactions in a Database
a relation (table) in a relational database. It is a Management System (DBMS). These
fundamental concept used in relational properties guarantee data integrity, even in the
database theory, especially in normalization, event of power failures, crashes, or errors.
which is the process of organizing data to
minimize redundancy. 1⃣ Atomicity
Goal: Ensure that either the entire transaction
Formal De nition: is executed or none at all.
Let R be a relation with attributes X and Y. Example: In a bank transaction:
We say that there is a functional dependency Deduct ₹1000 from Account A.
from X to Y, written as:
X → Y Add ₹1000 to Account B.
This means: If any one of the steps fails, the entire
If two tuples (rows) have the same value for X, transaction is rolled back.
they must also have the same value for Y.
Mathematically: 2⃣ Consistency
For all tuples t1 and t2 in R, if Goal: Maintain data integrity by ensuring the
t1.X = t2.X then database is always in a valid state.
t1.Y = t2.Y Example: If a transaction violates a foreign
key, the DBMS will not allow it.
Explanation with Components:
X is called the determinant.
3⃣ Isolation
Y is called the dependent.
Goal: Ensure concurrent transactions don’t
The dependency means that X uniquely
affect each other's execution.
determines Y.
Example: Two users transferring money at the
same time won’t see partial or con icting
🧾 Example: data.
Consider a relation Employee(Emp_ID, Isolation Levels: Read Uncommitted, Read
Name, Department, Salary) Committed, Repeatable Read, Serializable.
If each employee has a unique ID, and this ID
determines the rest of the details:
4⃣ Durability
Emp_ID → Name, Department,
Goal: Once a transaction is committed, its
Salary
results are permanent, even if the system
This means:
crashes.
If two employees have the same Emp_ID, they
Example: If a user buys a product and the
must also have the same Name, Department,
server crashes after the con rmation, the
and Salary — which makes sense if Emp_ID is
purchase still persists in the database.
a primary key.
fi
fi
fl
What is a Transaction?types What is a Join in DBMS?
A join in a Database Management System
(DBMS) is an operation used to combine data
A transaction is a logical unit of work that from two or more tables based on a related
must be either completely executed or column between them—usually a foreign key.
It allows you to retrieve meaningful, combined
completely failed (rolled back). For information from multiple tables.
example: transferring money between two
bank accounts. 📘 Why Use Joins?
To combine related data stored in different tables.
To query data across relationships.
Scheduling Non-Scheduling To eliminate data duplication in database design
Aspect (via normalization).
Transactions Transactions
1. INNER JOIN
Uses a Returns only the rows that have matching values
Each transaction in both tables.
schedule to
executes
De nitio order SELECT *
independently FROM Employees
n concurrent
without INNER JOIN Departments
transaction ON Employees.Dept_ID =
coordination
operations Departments.Dept_ID;
2. LEFT JOIN (LEFT OUTER JOIN)
Multiple Returns all rows from the left table, and matching
Transactions run
Concurr transactions rows from the right table.
sequentially (one If no match, returns NULLs for right table
ency run
after another) columns.
simultaneously
SELECT *
Requires FROM Employees
Control concurrency LEFT JOIN Departments
No concurrency ON Employees.Dept_ID =
Mechani control (e.g., Departments.Dept_ID;
control needed
sm locking,
timestamps) 3. RIGHT JOIN (RIGHT OUTER JOIN)
Returns all rows from the right table, and
matching rows from the left table.
Higher (needs If no match, returns NULLs for left table columns.
Lower (no
Risk of proper control
overlapping SELECT *
Con icts to avoid FROM Employees
operations)
inconsistency) RIGHT JOIN Departments
ON Employees.Dept_ID =
Better system Poorer Departments.Dept_ID;
Perform
utilization and performance due to 4. FULL JOIN (FULL OUTER JOIN)
ance
throughput idle time Returns all rows when there is a match in either
table.
Non-matching rows from both sides will have
NULLs in place.
SELECT *
FROM Employees
FULL OUTER JOIN Departments
ON Employees.Dept_ID =
Departments.Dept_ID;
5. CROSS JOIN
Returns the Cartesian product of the two tables.
Every row from the rst table is paired with every
row from the second table.
Used rarely unless needed.
SELECT *
FROM Employees
CROSS JOIN Departments;
fi
fl
fi
What is Deadlock Handling in DBMS? Applications of Joins in DBMS
Joins are used to combine data from two or
Deadlock handling in a Database more related tables based on common
Management System (DBMS) refers to the
methods used to detect, prevent, or recover attributes. They're commonly used in real-
from deadlocks, which occur when two or world applications to avoid data duplication
more transactions are waiting inde nitely and maintain normalization.
for each other’s resources.
Real-World Applications of Joins:
🧩 What is a Deadlock?
A deadlock happens when:
Transaction T1 holds resource A and waits E-commerce Systems
for resource B. Join Customers, Orders, and Products
Transaction T2 holds resource B and waits tables to generate invoices or order summaries.
for resource A. Library Management System
➡ Both are stuck, waiting forever → Join Books, Members, and
Deadlock Borrowed_Books to check who borrowed
which book and when.
✅ Deadlock Handling Techniques University Management
There are three main strategies to handle Join Students, Courses, and
deadlocks:
Enrollments to nd which students are
1⃣ Deadlock Prevention enrolled in which courses.
Goal: Ensure the system never enters a Banking Systems
deadlock state. Join Accounts, Transactions, and
How: Users to display account statements and
Impose rules on how locks are acquired. balances.
Examples:
Wait-die and Wound-wait schemes. Healthcare
Acquire all resources at once. Join Patients, Doctors,
Enforce lock ordering. Appointments, and Prescriptions for
a full patient treatment history.
2⃣ Deadlock Avoidance
Goal: Analyze transactions before execution to
avoid unsafe states.
How:
Use algorithms like Banker's Algorithm or
Resource Allocation Graph.
Allow a transaction only if it won’t lead to
deadlock.

3⃣ Deadlock Detection and Recovery


Goal: Allow deadlocks, but detect and resolve
them when they happen.
How:
Use a Wait-For Graph to detect cycles.
Recover by:
Aborting one or more transactions.
Rolling back and restarting.
fi
fi
ACID Properties and Their Application Define Backup in the context of
database management.
ACID stands for Atomicity, Consistency,
Isolation, Durability, and these are essential De nition of Backup in Database
to ensure reliable transaction processing. Management
Pro In the context of Database Management, a
pert Description backup is a copy of the database (or parts of
y it) that is created and stored separately to
A – Ensures that all operations within a ensure that data can be recovered in case of
Ato transaction are completed successfully. data loss, system failure, corruption, or
mici If any part fails, the entire transaction is disaster.
ty rolled back.
C – Guarantees that a transaction will bring
Con the database from one valid state to 🧠 Purpose of a Backup:
siste another, maintaining all integrity
ncy constraints. To restore the database to a previous
I– consistent state after a crash or error.
Ensures that concurrent transactions
Isol
execute independently without affecting To prevent permanent data loss.
atio
each other's execution.
n
To support disaster recovery plans.
D–
Once a transaction is committed, the
Dur To allow rollback to a known point in time.
changes are permanent, even in the case
abili
of a system crash.
ty
🔄 Types of Database Backups:

Applications of ACID Properties:


Type Description
Banking Transactions (Atomicity)
Transfer of funds between two accounts must Full A complete copy of the entire
Backup database and its structure.
be fully completed or not at all.
Increme Only the data that has changed since
E-commerce (Consistency)
ntal the last backup is stored.
When placing an order, product inventory and
Differen Stores changes since the last full
user balance must remain valid after the
tial backup, not since the last backup.
transaction.
Logical Stores data using SQL statements
Multi-user Applications (Isolation)
Backup (e.g., INSERT, CREATE).
Two customers buying the last product at the
same time won't both succeed—only one Copies physical les
Physical
transaction will proceed. (like .db, .frm, .ibd) used by
Backup
the DBMS.
Data Backup & Recovery (Durability)
Once a transaction is con rmed (e.g., order
placed), it remains even if the system crashes
immediately after. 📦 Real-Life Example:

In a banking system, daily backups are made


so that in case of a crash, all account balances
and transaction data can be restored to the last
backup point, minimizing data loss and
nancial risk.
fi
fi
fi
fi
Types of Database Backups What are constraints in a database, and
why are they important? Types
Full Backup
🔹 A complete copy of the entire database In database management, constraints are rules
applied to table columns to enforce data integrity,
including all data, logs, and schemas.
accuracy, and validity. They restrict the type of data
🔹 Used as a base for other backups. that can be inserted, updated, or deleted, ensuring
🔹 Time-consuming but essential. that the database remains in a consistent and correct
state.
Incremental Backup Types of Constraints in DBMS
Here are the primary types of constraints
🔹 Backs up only the data changed since the
commonly used in relational databases:
last backup (full or incremental).
NOT NULL Constraint
🔹 Faster and requires less storage, but Description: Ensures that a column cannot have a
restore time is longer. NULL value.
Example: A name column in a students table
Differential Backup should never be empty.
🔹 Backs up all data changed since the last UNIQUE Constraint
full backup. Description: Ensures all values in a column are
different (no duplicates).
🔹 Requires more space than incremental but
Example: A username must be unique for each
faster to restore.
user.
Cold Backup (Of ine Backup) PRIMARY KEY Constraint
Description: Uniquely identi es each record in a
🔹 Taken when the database is shut down. table; combines NOT NULL and UNIQUE.
🔹 Ensures data consistency. Example: A student_id used to identify each
student.
🔹 Requires downtime.
FOREIGN KEY Constraint
Description: Creates a link between two tables;
Hot Backup (Online Backup)
ensures value in one table matches a primary key in
🔹 Taken while the database is running and another.
accessible. Example: student_id in grades table must
🔹 Used in 24/7 systems. exist in students table.
CHECK Constraint
🔹 Requires special tools or techniques to Description: Ensures all values in a column satisfy
ensure consistency. a speci c condition.
Example: age must be greater than 0: CHECK
Logical Backup
(age > 0).
🔹 Exports data as SQL statements (e.g., DEFAULT Constraint
INSERT, CREATE). Description: Sets a default value for a column if no
🔹 Useful for small databases or data value is provided during insertion.
migration. Example: If no country is entered, default is
'India': DEFAULT 'India'.
🔹 Not suitable for high-performance
recovery.
🎯 Importance of Constraints
Physical Backup Data Integrity: Constraints ensure that only valid
data is stored in the database, maintaining accuracy
🔹 Copies actual database les from disk
and consistency.
(e.g., .db, .frm).
Prevent Invalid Data: They prevent the entry of
🔹 Faster than logical backup. incorrect or inconsistent data, safeguarding against
🔹 Suitable for large and high-performance data anomalies.
environments. Maintain Relationships: Constraints like
FOREIGN KEY enforce referential integrity
between related tables.
fi
fl
fi
fi
Define data independence in database Aspect 4NF 5NF
management.What are the two types of
Depend
data independence?
ency Multivalued
Join Dependencies
Addres Dependencies
Data Independence refers to the capacity of a
sed
database system to change the schema at one
level without necessitating changes at the next Based
BCNF 4NF
higher level. This principle ensures that on
modi cations in data storage or structure do Eliminate Eliminate
not impact the overall system functionality, independent redundancy from
Goal
promoting exibility and scalability in multivalued complex join
database management. facts operations
Into relations Into relations
Decom
without where joins do not
🔄 Types of Data Independence positio
multivalued reintroduce
n
dependencies redundancy
1. Physical Data Independence
Examp
De nition: The ability to alter the physical Student-Course- Salesperson-
le
schema without affecting the logical schema. Hobby Product-Region
Scenari
Explanation: Changes at the physical level, relationships combinations
o
such as using different storage devices or le
structures, do not impact the conceptual
structure of the database. What is Normalization? Why is it
Example: Moving the database from a hard needed in database design?
drive to a solid-state drive (SSD) for
performance improvement should not require Normalization is a systematic approach in
changes to the database's logical design. relational database design aimed at organizing
data to minimize redundancy and enhance data
2. Logical Data Independence integrity. This process involves decomposing
De nition: The ability to modify the logical large, complex tables into smaller, well-
schema without altering the external schema or structured tables and establishing relationships
application programs. between them.
Explanation: Adjustments in the conceptual
design, like adding new elds or tables, do not Why is Normalization Needed in
necessitate changes in how end-users interact Database Design?
with the data. Reduces Data Redundancy: By eliminating
Example: Introducing a new column to a table duplicate data, normalization ensures that each
should not affect existing user interfaces or piece of information is stored only once,
applications that do not utilize that column. optimizing storage and preventing
inconsistencies.
Importance of Data Independence Enhances Data Integrity: Ensures that the
Enhanced Flexibility: Facilitates easy data remains accurate and consistent across the
adaptation to changes in data storage and database.
structure without disrupting system operations. Simpli es Maintenance: A well-normalized
Improved Maintainability: Simpli es database is easier to maintain and update, as
database maintenance by isolating changes to changes in data are localized to speci c tables.
speci c schema levels. Improves Query Performance: Structured
Cost Ef ciency: Reduces the need for data allows for more ef cient querying, as the
extensive modi cations in application database engine can access and manipulate
programs when database schemas evolve data more effectively.
fi
fi
fi
fi
fi
fi
fl
fi
fi
fi
fi
fi
fi
What is relational algebra? Explain Cross Join in detail.
How is relational algebra different from
A CROSS JOIN in SQL produces the
relational calculus?
Cartesian product of two tables, combining
Relational Algebra is a procedural query each row from the rst table with every row
language used in relational database from the second table. This operation is
management systems (RDBMS). It fundamental in relational database systems and
provides a set of operations that take one is used to generate all possible combinations
or more relations (tables) as input and between two datasets. Wikipedia
produce a new relation as output. These Key Characteristics of CROSS JOIN
operations include selection (σ), projection No Join Condition: Unlike other joins, a
(π), union (∪), set difference (−), Cartesian CROSS JOIN does not require a condition to
product (×), and rename (ρ) . Relational match rows between tables. Wikipedia
algebra serves as the theoretical Result Size: If Table A has m rows and Table B
foundation for SQL and other query has n rows, the result of a CROSS JOIN will
languages, enabling efficient data retrieval have m × n rows.
and manipulation. Use Cases: Often used in scenarios where all
combinations are needed, such as generating
Relational Algebra vs. Relational Calculus test data, creating matrices, or pairing each
While both relational algebra and relational item in one set with all items in another.
calculus are formal languages for querying 🧾 Syntax Examples
relational databases, they differ in their Explicit CROSS JOIN:
approach: sql
Relational Algebra: Procedural in nature, it CopyEdit
speci es how to obtain the desired result by SELECT *
detailing a sequence of operations to be FROM TableA
performed on the data. This approach is akin to CROSS JOIN TableB;
providing a recipe for data retrieval.
Relational Calculus: Non-procedural or
declarative, it focuses on what data to retrieve What is the division operation in
without specifying the sequence of operations. relational algebra?
It uses logical predicates to describe the tuples in one relation that are associated with
properties of the desired result set all tuples in another relation. It's particularly
useful for queries that involve phrases like "for
all" or "every."
What Is the Division Operation?
Given two relations:
R(A, B): A relation with attributes A and B.
S(B): A relation with attribute B.
The division R ÷ S yields a relation T(A) such
that for every tuple a in T, and for every tuple
b in S, the tuple (a, b) exists in R.
In simpler terms, it nds all A values in R that
are associated with every B value in S.
✅ Use Cases
Identifying students who have completed all
required courses.
Finding customers who have purchased all
products in a speci c category.
Determining employees who are assigned to all
projects within a department.
fi
fi
fi
fi
Describe the purpose and importance Write a short note on shadow paging
of each Normal Form (1NF, 2NF, 3NF, and how it helps in recovery.
BCNF).
📘 First Normal Form (1NF) Shadow Paging is a database recovery
technique that ensures atomicity and durability
Purpose: Ensure that the table structure is at,
—two key ACID properties—without relying
with no repeating groups or arrays.
on traditional logging mechanisms. It
Importance:
maintains data consistency by using a copy-on-
Eliminates repeating groups by ensuring that
write strategy during transactions.
each eld contains only atomic (indivisible)
How Shadow Paging Works
values.
Page Tables: The database system maintains
Establishes a unique primary key for each
two page tables: the current page table and
record.
the shadow page table.
Lays the foundation for further normalization
Transaction Start: When a transaction begins,
steps.
the system creates a copy of the current page
Second Normal Form (2NF)
table, known as the shadow page table.
Purpose: Eliminate partial dependencies of
Modi cations: Any changes made during the
non-prime attributes on a part of a composite
transaction are applied to new copies of the
primary key.
data pages. The current page table is updated to
Importance:
point to these new pages, while the shadow
Ensures that non-key attributes are fully
page table remains unchanged, pointing to the
functionally dependent on the entire primary
original data pages.
key.
Commit: Upon successful completion of the
Reduces data redundancy by separating data
transaction, the shadow page table is discarded,
into related tables.
and the current page table (with pointers to the
Prevents update anomalies related to partial
new pages) becomes the new reference for the
dependencies.
database.
📙 Third Normal Form (3NF) Crash Recovery: If a system crash occurs
Purpose: Remove transitive dependencies before the transaction commits, the system can
where non-key attributes depend on other non- revert to the shadow page table, ensuring that
key attributes. uncommitted changes are not applied, thus
Importance: maintaining data consistency.
Ensures that non-key attributes are only
dependent on the primary key. Advantages of Shadow Paging
Enhances data integrity by isolating data into Fast Recovery: Recovery after a crash is
appropriate tables. straightforward, as the system can simply use
Simpli es maintenance by reducing the the shadow page table to restore the database to
potential for inconsistent data. a consistent state .
Boyce-Codd Normal Form (BCNF) No Logging Required: Eliminates the need for
Purpose: Address anomalies not handled by log les, reducing overhead and simplifying
3NF, especially when multiple candidate keys the recovery process .
exist. Improved Fault Isolation: Transactions are
Importance: isolated; a failure in one does not affect others .
Ensures that every determinant is a candidate
key, eliminating redundancy caused by Disadvantages of Shadow Paging
functional dependencies. High Commit Overhead: Committing a
Provides a stricter normalization standard than transaction may require updating multiple
3NF. pages, leading to increased disk I/O .
Further reduces redundancy and potential Data Fragmentation: Creating new copies of
anomalies in complex database schemas. pages can lead to fragmentation, affecting
performance .
fi
fi
fi
fi
fl

You might also like