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