diff --git a/app/sem4/dbms/content/chapter4.tsx b/app/sem4/dbms/content/chapter4.tsx new file mode 100644 index 0000000..f73052d --- /dev/null +++ b/app/sem4/dbms/content/chapter4.tsx @@ -0,0 +1,146 @@ +export const Ch4Content = () => { + return ( +
+

+ Normalization is the process of + organizing a database to reduce redundancy and improve data integrity by + breaking large tables into smaller, well-structured ones. +

+ +
+ +
+

+ Why Normalize? +

+ +
+ +
+ +
+

+ Functional Dependency +

+ +
+

Exam Tip: FDs are the foundation of all normal forms. Master them first.

+
+
+ +
+ +
+

+ 1NF — First Normal Form +

+ +
+

Violation → Fix

+
{`❌ Not 1NF:
+StudentID | Courses
+101       | DBMS, OS, CN
+
+✅ 1NF:
+StudentID | Course
+101       | DBMS
+101       | OS
+101       | CN`}
+
+
+ +
+ +
+

+ 2NF — Second Normal Form +

+ +
+

Violation → Fix

+
{`❌ Not 2NF (PK = StudentID + CourseID):
+StudentID | CourseID | StudentName | Grade
+101       | CS401    | Zubair      | A
+
+StudentName depends only on StudentID (partial dependency).
+
+✅ 2NF: Split into two tables:
+Students(StudentID, StudentName)
+Enrollments(StudentID, CourseID, Grade)`}
+
+
+ +
+ +
+

+ 3NF — Third Normal Form +

+ +
+

Violation → Fix

+
{`❌ Not 3NF:
+StudentID | DeptID | DeptName
+101       | D01    | CSE
+
+DeptName depends on DeptID (not on StudentID) — transitive.
+
+✅ 3NF: Split:
+Students(StudentID, DeptID)
+Departments(DeptID, DeptName)`}
+
+
+ +
+ +
+

+ BCNF — Boyce-Codd Normal Form +

+ +
+

If a table is in BCNF, it is also in 3NF — but not vice versa. BCNF is stronger.

+
+
+ +
+ +
+

+ Decomposition +

+ +
+
+ ); +}; \ No newline at end of file diff --git a/app/sem4/dbms/content/chapter5.tsx b/app/sem4/dbms/content/chapter5.tsx new file mode 100644 index 0000000..aa54577 --- /dev/null +++ b/app/sem4/dbms/content/chapter5.tsx @@ -0,0 +1,126 @@ +export const Ch5Content = () => { + return ( +
+

+ A transaction is a sequence of + database operations treated as a single unit. Concurrency control ensures + multiple transactions run simultaneously without conflicts. +

+ +
+ +
+

+ ACID Properties +

+ +
+

Exam Tip: ACID is one of the most asked topics. Remember all four with the mnemonic: All Changes Isolated & Durable.

+
+
+ +
+ +
+

+ Transaction States +

+ +
+

State Flow

+
{`Active → Partially Committed → Committed
+Active → Failed → Aborted`}
+
+
+ +
+ +
+

+ Concurrency Problems +

+ +
+ +
+ +
+

+ Locking +

+ +
+ +
+ +
+

+ Two-Phase Locking (2PL) +

+ +
+

Once a transaction releases its first lock, it enters the shrinking phase and cannot acquire new locks.

+
+
+ +
+ +
+

+ Deadlock +

+ +
+

Deadlock Example

+
{`T1 holds Lock(A), waits for Lock(B)
+T2 holds Lock(B), waits for Lock(A)
+→ Deadlock! Neither can proceed.`}
+
+
+ +
+ +
+

+ Timestamp-Based Concurrency Control +

+ +
+
+ ); +}; \ No newline at end of file diff --git a/app/sem4/dbms/content/chapter6.tsx b/app/sem4/dbms/content/chapter6.tsx new file mode 100644 index 0000000..7bb75e0 --- /dev/null +++ b/app/sem4/dbms/content/chapter6.tsx @@ -0,0 +1,83 @@ +export const Ch6Content = () => { + return ( +
+

+ Indexing and{" "} + Hashing are techniques used to + speed up data retrieval in large databases without scanning every row. +

+ +
+ +
+

+ Why Indexing? +

+ +
+ +
+ +
+

+ Types of Indexes +

+ +
+

Dense index is faster to search but uses more space. Sparse index saves space but requires the file to be sorted.

+
+
+ +
+ +
+

+ B-Tree and B+ Tree +

+ +
+

B+ Tree Structure

+
{`Internal nodes: [10 | 20 | 30]
+                /    |    |    \\
+Leaf nodes: [5,8] [12,15] [22,25] [35,40]
+             ↔      ↔       ↔       ↔  (linked)`}
+
+
+ +
+ +
+

+ Hashing +

+ +
+

Use indexing (B+ Tree) for range queries. Use hashing for fast exact lookups.

+
+
+
+ ); +}; \ No newline at end of file diff --git a/app/sem4/dbms/content/chapter7.tsx b/app/sem4/dbms/content/chapter7.tsx new file mode 100644 index 0000000..a26f921 --- /dev/null +++ b/app/sem4/dbms/content/chapter7.tsx @@ -0,0 +1,90 @@ +export const Ch7Content = () => { + return ( +
+

+ Query Processing is how the DBMS + takes a SQL query, understands it, and executes it efficiently.{" "} + Query Optimization selects the + most efficient execution plan. +

+ +
+ +
+

+ Steps in Query Processing +

+ +
+

Query Processing Pipeline

+
{`SQL Query
+   ↓ Parser
+Parse Tree
+   ↓ Translator
+Relational Algebra Expression
+   ↓ Optimizer
+Execution Plan
+   ↓ Evaluator
+Query Result`}
+
+
+ +
+ +
+

+ Query Cost Estimation +

+ +
+ +
+ +
+

+ Join Algorithms +

+ +
+

Hash Join is generally the fastest for large datasets. Merge Join is best when data is already sorted.

+
+
+ +
+ +
+

+ Query Optimization Techniques +

+ +
+

Heuristic Example

+
{`-- Before optimization (filter happens after join):
+Students ⋈ Enrollments WHERE Students.dept = 'CSE'
+
+-- After optimization (filter before join):
+σ(dept='CSE')(Students) ⋈ Enrollments`}
+
+
+
+ ); +}; \ No newline at end of file diff --git a/app/sem4/dbms/content/chapter8.tsx b/app/sem4/dbms/content/chapter8.tsx new file mode 100644 index 0000000..9f91f13 --- /dev/null +++ b/app/sem4/dbms/content/chapter8.tsx @@ -0,0 +1,117 @@ +export const Ch8Content = () => { + return ( +
+

+ Recovery restores the database to + a consistent state after a failure.{" "} + Security ensures only authorized + users can access or modify data. +

+ +
+ +
+

+ Types of Failures +

+ +
+ +
+ +
+

+ Log-Based Recovery +

+ +
+

WAL is the golden rule of recovery — always log before you change.

+
+
+ +
+ +
+

+ Checkpoints +

+ +
+

Recovery After Crash

+
{`Checkpoint at T=10
+T1 committed at T=8  → already safe, skip
+T2 committed at T=12 → redo (may not be on disk)
+T3 active at crash   → undo (was never committed)`}
+
+
+ +
+ +
+

+ Shadow Paging +

+ +
+ +
+ +
+

+ Database Security +

+ +
+ +
+ +
+

+ SQL Injection +

+ +
+

SQL Injection Example

+
{`-- Vulnerable query:
+"SELECT * FROM users WHERE name = '" + input + "'"
+
+-- Attacker enters: ' OR '1'='1
+-- Resulting query (returns all users!):
+SELECT * FROM users WHERE name = '' OR '1'='1'
+
+-- Safe fix (prepared statement):
+SELECT * FROM users WHERE name = ?`}
+
+
+
+ ); +}; \ No newline at end of file