Database Management Systems (DBMS) - Simplified Notes
UNIT I: Basics of DBMS
----------------------
1. Database Instance vs Schema:
- Schema = blueprint (structure/design)
- Instance = actual data stored
2. Applications: Used in banks, hospitals, companies, schools, etc.
3. Advantages of DBMS:
- Reduces data duplication
- Better security and access control
- Easy data backup and recovery
4. Data Independence: You can change data structure without affecting applications.
5. Database Architecture:
- 1-tier: DBMS and application on the same machine
- 2-tier: Client connects to database server
- 3-tier: Client -> Application Server -> DB Server
6. Primary Key vs Candidate Key:
- Primary Key: Uniquely identifies each row
- Candidate Key: All possible keys that can act as primary key
7. Data Models: Way to organize data, e.g., Hierarchical, Network, Relational
UNIT II: ER Model & Normalization
----------------------------------
1. Entity = Thing (like student, employee)
2. Attributes = Details of entity (like name, age)
3. Relationships = How entities are connected (e.g., student enrolls in course)
4. ER Diagram = Visual representation of data and relationships
5. Normalization:
- Process to reduce data redundancy
- 1NF: Remove repeating groups
- 2NF: Remove partial dependency
- 3NF: Remove transitive dependency
- BCNF: Advanced version of 3NF
6. Functional Dependency: One column's value depends on another (e.g., Roll No -> Name)
7. Closure of Attributes: All attributes that can be functionally determined
UNIT III: SQL & Relational Algebra
----------------------------------
1. SQL = Language to manage databases
- DDL: Create, alter, drop tables
- DML: Insert, delete, update data
2. Relational Algebra = Theory behind SQL
- Operators like SELECT, PROJECT, JOIN, UNION
3. SQL Commands:
- GROUP BY: Group rows by column
- Aggregate Functions: COUNT, SUM, AVG, MAX, MIN
- JOIN: Combine rows from multiple tables
- Nested Query: Query inside another query
4. Examples:
- Get employees without supervisors
- Find employees in HR department
UNIT IV: Transactions & Advanced Topics
----------------------------------------
1. Views: Virtual table created using a query
2. Constraints: Rules like NOT NULL, UNIQUE, FOREIGN KEY
3. Triggers: Automatic actions on data change (e.g., log on insert)
4. Transaction = Group of SQL operations done together
5. ACID Properties:
- Atomicity - All or none
- Consistency - Data must be valid
- Isolation - No interference
- Durability - Changes are permanent
6. Indexes: Help find data faster (like book index)
7. COMMIT & ROLLBACK:
- COMMIT: Save changes
- ROLLBACK: Undo changes
UNIT V: Security & Performance
-------------------------------
1. Privileges: Define what users can do (e.g., read, write)
2. User Roles: Groups of permissions (e.g., admin, guest)
3. Backup: Copy of data for recovery
4. Normalization Benefits: Clean, reliable data
5. Performance Tuning: Make queries faster and efficient