DBMS COMPLETE NOTES (UNIT I – V)
UNIT I – DBMS BASICS
1. Basic Architecture of DBMS
DBMS architecture consists of:
• Database
• DBMS software
• Query processor
• Storage manager
• Users
Three main layers:
External level, Conceptual level, Internal level.
2. File System vs DBMS
File System:
- Data redundancy
- No security
- No concurrency
DBMS:
- Reduced redundancy
- High security
- Supports concurrency
3. Three-Level Schema Architecture
• External Schema – User view
• Conceptual Schema – Logical structure
• Internal Schema – Physical storage
4. ER Model
Entity Relationship model represents data logically.
Symbols:
• Rectangle – Entity
• Oval – Attribute
• Diamond – Relationship
• Double rectangle – Weak entity
5. Weak Entity Set
Entity without primary key.
Example: Dependent depends on Employee.
6. Generalization / Specialization / Aggregation
Generalization: Bottom to top.
Specialization: Top to bottom.
Aggregation: Relationship between relationships.
7. Functions of DBA
• Schema definition
• Security control
• Backup and recovery
• Performance monitoring
8. Hierarchical vs Network DBMS
Hierarchical:
- Tree structure
Network:
- Graph structure
9. Data Independence
Ability to change schema without affecting applications.
Types:
• Logical
• Physical
10. Indexing and Hashing
Indexing improves search speed.
Hashing maps data using hash function.
--------------------------------------------------
UNIT II – RELATIONAL MODEL & SQL
1. SELECT, PROJECT, UNION
SELECT: Choose rows
PROJECT: Choose columns
UNION: Combine relations
2. Fundamental Operations
Selection, Projection, Union, Difference, Cartesian Product
3. Tuple vs Domain Relational Calculus
Tuple: Based on tuples
Domain: Based on attributes
4. NULL Values
Represents unknown or missing values.
5. Keys
Super Key – Any unique set
Candidate Key – Minimal super key
Primary Key – Selected candidate key
Foreign Key – Reference key
6. RA Queries (Student Table)
σ (marks > 60)(Student)
π (name, roll)(Student)
7. Join Operations
Inner, Left, Right, Full Outer Join
8. Full Outer Join SQL
SELECT * FROM A FULL OUTER JOIN B ON [Link] = [Link];
9. EMP/DEPT Queries
SELECT * FROM emp WHERE sal > 3000;
10. View
CREATE VIEW v1 AS SELECT * FROM emp;
DROP VIEW v1;
ALTER VIEW v1 AS SELECT name FROM emp;
--------------------------------------------------
UNIT III – NORMALIZATION
1. Functional Dependency
A → B means A determines B.
2. Anomalies
Insert, Update, Delete anomaly.
3. 1NF, 2NF, 3NF
1NF: Atomic values
2NF: No partial dependency
3NF: No transitive dependency
4. BCNF
Stronger than 3NF.
Every determinant must be candidate key.
5. 3NF to BCNF Steps
• Identify violating FD
• Decompose relation
6. Lossless vs Dependency Preserving
Lossless: No data loss
Dependency preserving: FD maintained
7. Query Optimization
Process of minimizing execution cost.
--------------------------------------------------
UNIT IV – TRANSACTIONS
1. Transaction
Sequence of operations.
ACID:
Atomicity, Consistency, Isolation, Durability
2. Concurrency Control
Needed to avoid inconsistency.
3. 2PL vs Strict 2PL
2PL: Two phases
Strict: Locks released after commit
4. Timestamp Protocol
Transactions executed based on timestamp.
5. Log Based Recovery
Uses log file for undo/redo.
6. Conflict Serializability
Schedules equivalent to serial schedule.
7. Multiple Granularity Concurrency Control
Locks at different levels (table, page, row).
8. Validation Based Protocol
Uses read, validation, write phases.
--------------------------------------------------
UNIT V – PL/SQL & ADVANCED
1. Cursor
Used to process query result.
Types:
• Implicit
• Explicit
2. Exception Handling
EXCEPTION
WHEN NO_DATA_FOUND THEN ...
3. Trigger
Automatically executed on events.
Example:
CREATE TRIGGER trg BEFORE INSERT ON emp;
4. CREATE / ALTER / DROP
CREATE TABLE emp(id INT);
ALTER TABLE emp ADD sal INT;
DROP TABLE emp;
5. Short Notes
Distributed Database:
Data stored at multiple locations.
Web & Mobile Databases:
Used in online applications.
Oracle APEX:
Low-code web application development tool.