ADBMS notes
ADBMS notes
1. Functional dependency
What is Functional Dependency?
Functional Dependency (FD) is a constraint between two sets of
attributes in a relation (table). It expresses a relationship where
one attribute uniquely determines another attribute.
Notation:
X→YX \right arrow YX→Y
This means that if two rows have the same value for X, then they
must also have the same value for Y.
• X → Determinant (Left side)
• Y → Dependent (Right side)
102 Bob IT
Student_ID).
3. Partial Functional Dependency
o When a non-key attribute is dependent on a part of the
primary key (in composite keys).
o Example: {Student_ID, Course_ID} → Student_Name
(Student_Name depends only on Student_ID, not
Course_ID).
4. Full Functional Dependency
o A non-key attribute is dependent on the entire composite
key.
o Example: {Student_ID, Course_ID} → Grade (Grade
2. Third nf
What is Third Normal Form (3NF)?
Third Normal Form (3NF) is a database normalization rule that
helps reduce redundancy and improve data integrity.
A relation (table) is in 3NF if:
1. It is in Second Normal Form (2NF) (i.e., no partial
dependencies).
2. There is no transitive dependency (i.e., non-key attributes
should not depend on other non-key attributes).
Transitive Dependency:
If A → B and B → C, then A → C (this is a transitive
dependency).
To be in 3NF, we must remove transitive dependencies.
Example of 3NF
Before 3NF (Not in 3NF)
Student_ID Student_Name Department HOD
102 Bob IT
IT Dr. John
Advantages of 3NF
Reduces data redundancy
Avoids update anomalies
Improves database efficiency
102 OS
103 DBMS
104 OS
Instructor Table (Now in BCNF)
Course Instructor
DBMS Dr. Smith
Course Instructor
OS Dr. John
Advantages of BCNF
✔ Eliminates redundancy more effectively than 3NF
✔ Prevents update anomalies completely
✔ Ensures a more robust database structure
4. Referential integrity
Referential Integrity ensures that relationships between tables
remain consistent in a database.
2 IT
3 ECE
Table 2: Student (Dependent Table)
Student_ID (Primary Dept_ID (Foreign
Name Key)
Key)
101 Alice 1
102 Bob 2
103 Charlie 3
Example in SQL
CREATE TABLE Department (
Dept_ID INT PRIMARY KEY,
Dept_Name VARCHAR(50)
);
Key Features
class Book:
def __init__(self, book_id, title, author):
self.book_id = book_id
self.title = title
self.author = author
def borrow(self):
print(f"{self.title} is borrowed.")
# Creating an object
book1 = Book(101, "OOP Principles", "E. Balagurusamy")
book1.borrow() # Output: OOP Principles is borrowed.
Disadvantages
✘ Not as widely supported as RDBMS.
✘ More complex to design & manage.
✘ No standard query language (uses OQL instead of SQL).
def display(self):
print(f"Book: {self.title} by {self.author}")
Disadvantages of OODB
1. Complexity in Design & Implementation
o OODB is more complex to design than relational
databases due to object relationships.
2. Not Standardized
o Unlike SQL (which is standard for RDBMS), OODB
lacks a universal query language (OQL is used but not
widely adopted).
3. Limited Support & Adoption
o Most organizations use RDBMS (e.g., MySQL,
✔ Example:
• Single large server with multiple processors (e.g., Oracle
Database on a high-performance server).
✔ Advantages:
Fast communication between processors (since they share
memory).
Easy to program and manage since all CPUs access the same
data.
Disadvantages:
Memory bottleneck – When too many CPUs try to access the
same memory, performance decreases.
Scalability issues – Adding more processors makes
synchronization difficult.
✔ Example:
• Clustered database systems (e.g., Oracle RAC (Real
1 Authentication Types
1. Password-Based – Users log in with a password (stored
securely using hashing).
✔ Example (SQL User Table):
CREATE TABLE Users (
UserID INT PRIMARY KEY,
Username VARCHAR(50) UNIQUE,
PasswordHash VARCHAR(255) -- Hashed storage
);
2. Multi-Factor (MFA) – Combines:
✔ Password (Something you know)
✔ OTP/Token (Something you have)
✔ Fingerprint/Face ID (Something you are)
3. Token-Based (JWT) – Server issues a token after login for
future authentication.
✔ Example:
{ "user_id": 101, "role": "admin", "exp": 1715996400 }
2 Best Practices
11. Trigger
Trigger in ADBMS (Advanced Database Management
Systems)
A trigger is a special type of stored procedure in a database that
automatically executes when a specified event occurs in a table.
Why Use Triggers?
Automatically enforce business rules
Maintain data integrity
Log changes in a table
Restrict unauthorized modifications
1 Types of Triggers
Type Description
2 Creating a Trigger
Example 1: Trigger to Prevent Negative Salary
CREATE TRIGGER prevent_negative_salary
BEFORE INSERT OR UPDATE ON Employees
FOR EACH ROW
BEGIN
IF NEW.salary < 0 THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Salary cannot be negative';
END IF;
END;
✔ Explanation:
• Runs before INSERT or UPDATE on Employees.
3Advantages of Triggers
✔ Automatic Execution – Runs without manual intervention.
✔ Enforces Business Rules – Ensures valid data entry.
✔ Maintains Data Integrity – Prevents invalid transactions.
S
4 Disadvantages of Triggers
Hard to Debug – Errors in triggers are difficult to trace.
Performance Impact – Too many triggers slow down the
database.
Hidden Execution – Runs automatically, making tracking
difficult.