+ );
+}
\ No newline at end of file
diff --git a/app/sem4/dbms/components/sidebar.tsx b/app/sem4/dbms/components/sidebar.tsx
new file mode 100644
index 0000000..e091292
--- /dev/null
+++ b/app/sem4/dbms/components/sidebar.tsx
@@ -0,0 +1,73 @@
+"use client";
+import { Righteous } from "next/font/google";
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+import { useState } from "react";
+
+const righteous = Righteous({
+ subsets: ["latin"],
+ weight: "400",
+ variable: "--font-righteous",
+});
+
+export default function Sidebar() {
+ const pathname = usePathname();
+ const [open, setOpen] = useState(true);
+
+ const chapters = [
+ { id: "ch0", title: "Course Outline" },
+ { id: "ch1", title: "Introduction to Databases" },
+ { id: "ch2", title: "Entity-Relationship Model" },
+ { id: "ch3", title: "Relational Model and SQL" },
+ // { id: "ch4", title: "Normalization" },
+ // { id: "ch5", title: "Transactions and Concurrency Control" },
+ // { id: "ch6", title: "Indexing and Hashing" },
+ // { id: "ch7", title: "Query Processing and Optimization" },
+ // { id: "ch8", title: "Recovery and Security" },
+ ];
+
+ return (
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/app/sem4/dbms/content/chapter0.tsx b/app/sem4/dbms/content/chapter0.tsx
new file mode 100644
index 0000000..044002b
--- /dev/null
+++ b/app/sem4/dbms/content/chapter0.tsx
@@ -0,0 +1,149 @@
+export const Ch0Content = () => {
+ return (
+
+
+ Welcome to Database Management Systems —
+ a core course designed to help you understand how data is organized, stored,
+ retrieved, and managed efficiently. This course covers relational models, SQL,
+ normalization, transactions, indexing, and more.
+
+
+
+
+
+
+ Module I: Introduction to Databases
+
+
+
What is a database and why we need it
+
File system vs database approach
+
Advantages of DBMS over file systems
+
Types of databases: relational, hierarchical, network, object-oriented
+
Database users: end users, application programmers, DBA
+
DBMS architecture: 1-tier, 2-tier, 3-tier
+
+
+
+
+
+
+
+ Module II: Entity-Relationship Model
+
+
+
Entities, attributes, and relationships
+
Types of attributes: simple, composite, multivalued, derived
Concurrency problems: lost update, dirty read, unrepeatable read
+
Concurrency control techniques: locking, timestamps
+
Two-phase locking protocol
+
Deadlock detection and recovery
+
+
+
+
+
+
+
+ Module VI: Indexing and Hashing
+
+
+
Basic concepts of indexing
+
Dense and sparse indexes
+
B-tree and B+ tree indexing
+
Hashing techniques: static and dynamic
+
Comparison of indexing vs hashing
+
When to use which technique
+
+
+
+
+
+
+
+ Module VII: Query Processing and Optimization
+
+
+
Steps in query processing
+
Query cost estimation
+
Equivalence of relational expressions
+
Query optimization techniques
+
Nested loop joins and merge joins
+
Query execution plans
+
+
+
+
+
+
+
+ Module VIII: Recovery and Security
+
+
+
Types of failures: transaction, system, media
+
Recovery techniques: log-based, shadow paging
+
Checkpoints and their role in recovery
+
Database security concepts
+
Authorization and authentication
+
SQL injection and prevention
+
+
+
+
+
+
+ By the end of this course, you will understand how to design databases,
+ write efficient SQL queries, normalize data, manage transactions, and
+ handle indexing and recovery — providing a strong foundation for
+ real-world database development and system design.
+
+ This chapter covers the fundamental concepts of database systems — what
+ they are, why they exist, how they compare to file systems, and the
+ basic architecture of a DBMS.
+
+
+
+
+
+
+ What is a Database?
+
+
+
A database is an organized collection of related data stored and accessed electronically.
+
Data represents real-world information — student records, bank transactions, product inventory.
+
A DBMS (Database Management System) is software that manages and controls access to the database.
+
Examples of DBMS: MySQL, PostgreSQL, Oracle, MongoDB.
+
+
+
Real-world Example
+
{`University DB
+Tables: Students, Courses, Enrollments, Professors
+Student Zubair (ID: 101) is enrolled in DBMS (CS401)
+taught by Prof. Sharma.`}
+
+
+
+
+
+
+
+ File System vs DBMS
+
+
+
Before DBMS, data was stored in flat files managed by the OS.
+
Data Redundancy: the same data repeated in multiple files.
+
Data Inconsistency: updating one file does not update others.
+
Data Isolation: data scattered in different formats, hard to access together.
+
DBMS solves all three by centralizing data and enforcing rules.
+
+
+
Exam Tip: Always mention the 3 main problems of file systems — redundancy, inconsistency, and data isolation — when comparing with DBMS.
+
+
+
+
+
+
+
+ Advantages of DBMS
+
+
+
Reduced Redundancy: data is stored once and shared.
+
Data Consistency: changes reflect everywhere automatically.
+
Data Integrity: constraints ensure data accuracy.
+
Data Security: access control limits who can read or modify data.
+
Concurrent Access: multiple users can safely access data at the same time.
+
Backup and Recovery: DBMS provides tools to recover from failures.
+
+
+
+
+
+
+
+ Types of Databases
+
+
+
Relational: data in tables with rows and columns. Example: MySQL, PostgreSQL.
+
Hierarchical: tree-like structure. Example: IBM IMS.
+
Network: graph structure with multiple parent-child relationships.
+
Object-Oriented: stores objects like in OOP. Example: db4o.
+
NoSQL: designed for unstructured data at scale. Example: MongoDB, Redis.
+
+
+
Most university syllabi focus on relational databases. NoSQL is mentioned for awareness.
+
+
+
+
+
+
+
+ Database Users
+
+
+
End Users: interact with the database through applications.
+
Application Programmers: write programs to access the database.
+
DBA (Database Administrator): manages performance, security, and backups.
+
Data Analysts: query the database to generate reports and insights.
+
+
+
Who does what?
+
{`End User → Uses a form to register for a course
+App Dev → Writes INSERT INTO enrollments...
+DBA → Creates tables, grants permissions, monitors performance`}
+
+
+
+
+
+
+
+ Three-Schema Architecture
+
+
+
DBMS uses a 3-level architecture to separate storage from how users see data.
+
Internal Level: how data is physically stored on disk.
+
Conceptual Level: the logical structure — tables, relationships, constraints.
+
External Level: what individual users or applications see (views).
+
This separation is called Data Independence.
+
+
+
Physical independence = change storage without changing logic. Logical independence = change logic without changing user views.
DCL (Data Control Language): access control. Example: GRANT, REVOKE.
+
TCL (Transaction Control Language): manage transactions. Example: COMMIT, ROLLBACK.
+
+
+
Quick Examples
+
{`DDL: CREATE TABLE students (id INT PRIMARY KEY, name VARCHAR(50));
+DML: INSERT INTO students VALUES (1, 'Zubair');
+DCL: GRANT SELECT ON students TO user1;
+TCL: COMMIT;`}
+
+
+
+
+
+
+
+ DBMS Architecture: 1-Tier, 2-Tier, 3-Tier
+
+
+
1-Tier: database and application on the same machine. Used for personal/local databases.
+
2-Tier: client communicates directly with the database server.
+
3-Tier: a middle application server sits between client and database. Used in web apps.
+
+
+
3-Tier Example
+
{`Client (Browser)
+ ↓ HTTP request
+App Server (Node.js / Spring Boot)
+ ↓ SQL query
+Database Server (MySQL / PostgreSQL)`}
+
+
+
+ );
+};
\ No newline at end of file
diff --git a/app/sem4/dbms/content/chapter2.tsx b/app/sem4/dbms/content/chapter2.tsx
new file mode 100644
index 0000000..810c554
--- /dev/null
+++ b/app/sem4/dbms/content/chapter2.tsx
@@ -0,0 +1,127 @@
+export const Ch2Content = () => {
+ return (
+
+
+ The Entity-Relationship (ER) Model is
+ a high-level conceptual tool used to design databases visually before writing
+ any SQL. It represents real-world data as entities, their attributes, and
+ their relationships.
+
+
+
+
+
+
+ What is the ER Model?
+
+
+
The ER Model is a blueprint for designing a database before coding.
+
It helps translate real-world requirements into a visual diagram.
+
Proposed by Peter Chen in 1976.
+
The ER Diagram (ERD) is later converted into relational tables.
+
+
+
+
+
+
+
+ Entities and Entity Sets
+
+
+
An Entity is a real-world object — a student, a course, an employee.
+
An Entity Set is a collection of similar entities — all students, all courses.
+
Strong Entity: can exist independently. Example: Student.
+
Weak Entity: depends on another entity. Example: Dependent (of an employee).
+
+
+
In ER diagrams: Strong entities use a single rectangle. Weak entities use a double rectangle.
+
+
+
+
+
+
+
+ Attributes
+
+
+
Simple: cannot be divided further. Example: Age.
+
Composite: can be divided into sub-parts. Example: Name → First Name, Last Name.
+
Multivalued: can have more than one value. Example: Phone Numbers.
+
Derived: calculated from other attributes. Example: Age from Date of Birth.
+
Key Attribute: uniquely identifies each entity. Example: Student ID.
Binary: between two entities. Example: Student enrolls in Course.
+
Ternary: between three entities. Example: Doctor prescribes Medicine to Patient.
+
Relationships can also have attributes. Example: 'enrolls' can have a 'grade' attribute.
+
+
+
+
+
+
+
+ Cardinality
+
+
+
Cardinality defines how many entity instances participate in a relationship.
+
One-to-One (1:1): A person has one passport.
+
One-to-Many (1:N): One department has many employees.
+
Many-to-Many (M:N): A student enrolls in many courses; a course has many students.
+
+
+
Cardinality Notation
+
{`1:1 → Person ——— Passport
+1:N → Department ——< Employee
+M:N → Student >——< Course`}
+
+
+
+
+
+
+
+ Participation Constraints
+
+
+
Total Participation: every entity must participate in the relationship. Shown with a double line.
+
Partial Participation: some entities may not participate. Shown with a single line.
+
Example: Every employee must work for a department (total), but not every department must have a manager (partial).
+
+
+
+
+
+
+
+ Extended ER Features
+
+
+
Specialization: dividing an entity into sub-entities. Example: Employee → Manager, Engineer, Clerk. (Top-down)
+
Generalization: combining multiple entities into one. Example: Car + Truck → Vehicle. (Bottom-up)
+
Aggregation: treating a relationship as an entity to allow relationships with other entities.
+
Inheritance: sub-entities inherit attributes from the parent entity.
+
+
+
Specialization is top-down. Generalization is bottom-up. Both lead to the same result in the ERD.
+
+
+
+ );
+};
\ No newline at end of file
diff --git a/app/sem4/dbms/content/chapter3.tsx b/app/sem4/dbms/content/chapter3.tsx
new file mode 100644
index 0000000..7337aea
--- /dev/null
+++ b/app/sem4/dbms/content/chapter3.tsx
@@ -0,0 +1,183 @@
+export const Ch3Content = () => {
+ return (
+
+
+ The Relational Model organizes data
+ into tables (relations) and is the foundation of most modern databases.
+ SQL (Structured Query Language) is
+ the standard language used to interact with relational databases.
+
+
+
+
+
+
+ Relational Model Basics
+
+
+
Data is organized in tables (relations) with rows and columns.
+
Each row is called a tuple and represents one record.
+
Each column is called an attribute and represents a property.
+
The set of allowed values for an attribute is called its domain.
+
The number of tuples in a table is called cardinality.
+
The number of attributes in a table is called degree.
Super Key: any set of attributes that uniquely identifies a tuple.
+
Candidate Key: minimal super key — no unnecessary attributes.
+
Primary Key: the chosen candidate key used to identify tuples. Cannot be NULL.
+
Foreign Key: an attribute that references the primary key of another table. Used to link tables.
+
Composite Key: a primary key made of more than one attribute.
+
+
+
Exam Tip: Every primary key is a candidate key, and every candidate key is a super key — but not the other way around.
+
+
+
+
+
+
+
+ Relational Algebra
+
+
+
Select (σ): filters rows based on a condition. Example: σ(Dept='CSE')(Students).
+
Project (π): selects specific columns. Example: π(Name, Age)(Students).
+
Union (∪): combines tuples from two relations (removes duplicates).
+
Intersection (∩): returns tuples common to both relations.
+
Difference (−): returns tuples in one relation but not the other.
+
Cartesian Product (×): combines every tuple of one relation with every tuple of another.
+
Join (⋈): combines related tuples from two relations based on a condition.
+
+
+
+
+
+
+
+ SQL Basics
+
+
+
DDL: CREATE, ALTER, DROP, TRUNCATE.
+
DML: SELECT, INSERT, UPDATE, DELETE.
+
DCL: GRANT, REVOKE.
+
TCL: COMMIT, ROLLBACK, SAVEPOINT.
+
+
+
Basic SQL Examples
+
{`-- Create table
+CREATE TABLE students (
+ id INT PRIMARY KEY,
+ name VARCHAR(50),
+ dept VARCHAR(20)
+);
+
+-- Insert data
+INSERT INTO students VALUES (101, 'Zubair', 'CSE');
+
+-- Query data
+SELECT name, dept FROM students WHERE dept = 'CSE';
+
+-- Update data
+UPDATE students SET dept = 'IT' WHERE id = 101;
+
+-- Delete data
+DELETE FROM students WHERE id = 101;`}
+
+
+
+
+
+
+
+ Joins
+
+
+
Inner Join: returns rows that have matching values in both tables.
+
Left Outer Join: returns all rows from the left table and matched rows from the right.
+
Right Outer Join: returns all rows from the right table and matched rows from the left.
+
Full Outer Join: returns all rows when there is a match in either table.
+
Natural Join: automatically joins on columns with the same name.
+
Cross Join: returns the Cartesian product of both tables.
+
+
+
Join Example
+
{`-- Inner Join: students with their enrolled courses
+SELECT students.name, courses.title
+FROM students
+INNER JOIN enrollments ON students.id = enrollments.student_id
+INNER JOIN courses ON enrollments.course_id = courses.id;`}
+
+
+
+
+
+
+
+ Aggregate Functions and GROUP BY
+
+
+
COUNT(): counts number of rows.
+
SUM(): adds up values in a column.
+
AVG(): calculates the average.
+
MAX() / MIN(): finds the highest or lowest value.
+
GROUP BY: groups rows with the same value for aggregation.
+
HAVING: filters groups (like WHERE but for aggregated results).
+
+
+
Aggregate Example
+
{`-- Count students per department
+SELECT dept, COUNT(*) AS total
+FROM students
+GROUP BY dept
+HAVING COUNT(*) > 1;`}
+
+
+
+
+
+
+
+ Subqueries and Views
+
+
+
A subquery is a query nested inside another query.
+
Subqueries can be used in SELECT, FROM, or WHERE clauses.
+
A view is a virtual table based on the result of a SELECT query.
+
Views simplify complex queries and add a layer of security.
+
+
+
Subquery and View Example
+
{`-- Subquery: students older than average age
+SELECT name FROM students
+WHERE age > (SELECT AVG(age) FROM students);
+
+-- Create a view
+CREATE VIEW cse_students AS
+SELECT name, age FROM students WHERE dept = 'CSE';
+
+-- Use the view
+SELECT * FROM cse_students;`}
+
+
+
+ );
+};
\ No newline at end of file
diff --git a/app/sem4/dbms/layout.tsx b/app/sem4/dbms/layout.tsx
new file mode 100644
index 0000000..faa7cd6
--- /dev/null
+++ b/app/sem4/dbms/layout.tsx
@@ -0,0 +1,28 @@
+import Navbar from "../../components/navbar";
+ import Sidebar from "./components/sidebar";
+
+export const metadata = {
+ title: "Database Management Systems | openCSE",
+ description:
+ "Free and Open Documentations for Database Management Systems",
+};
+
+export default function DBMSLayout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ return (
+
+
+
+
+
+
+ {children}
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/app/sem4/dbms/page.tsx b/app/sem4/dbms/page.tsx
new file mode 100644
index 0000000..c7daade
--- /dev/null
+++ b/app/sem4/dbms/page.tsx
@@ -0,0 +1,8 @@
+export default function Home() {
+ return (
+