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