IT404 Unit 2
IT405 โ€ข Database Management System

DBMS Unit 2 Notes

Relational Model, SQL, Relational Algebra and Integrity Constraints

Complete RGPV IT405 Database Management System Unit 2 notes for B.Tech students. This unit covers Relational Model, Relational Algebra, Relational Calculus, SQL Commands (DDL, DML, DCL, TCL), Joins, Nested Queries, Views and Integrity Constraints in easy exam-oriented Hinglish language with examples, important questions and PYQ analysis.

๐Ÿ“˜

Detailed Notes

Learn Relational Model, SQL commands, Relational Algebra, Relational Calculus, Joins, Views and Integrity Constraints with easy explanations and practical examples.

Read Notes
โญ

Important Questions

Prepare important 2 marks, 5 marks, 7 marks and 14 marks questions from SQL, Relational Algebra, Joins and Integrity Constraints.

View Questions
๐Ÿ“„

PYQ Analysis

Check repeated RGPV questions, exam trends and 2026 predictions for DBMS Unit 2.

Open Analysis

DBMS Unit 2 Syllabus Topics

Relational Model Relational Algebra Relational Calculus Introduction to SQL DDL Commands DML Commands DCL Commands TCL Commands SQL Joins Nested Queries Views Integrity Constraints Important Questions PYQ Analysis FAQs

What You Will Learn in DBMS Unit 2?

DBMS Unit 2 is one of the most practical and scoring units in the Database Management System syllabus. In this unit, students learn how data is stored inside tables and how SQL is used to retrieve, insert, update and delete data.

This unit forms the foundation of database programming, web development, backend development and software engineering. Almost every company uses SQL databases, making this unit extremely important for both examinations and placements.

UNIT 2 ROADMAP โ†“ Relational Model โ†“ Relational Algebra โ†“ Relational Calculus โ†“ SQL โ†“ DDL โ†“ DML โ†“ DCL โ†“ TCL โ†“ Joins โ†“ Views โ†“ Integrity Constraints
IT405 โ€ข Database Management System

DBMS Unit 2 Notes

Relational Model, SQL, Relational Algebra and Integrity Constraints

Complete RGPV IT405 Database Management System Unit 2 notes for B.Tech students. This unit covers Relational Model, Relational Algebra, Relational Calculus, SQL Commands (DDL, DML, DCL, TCL), Joins, Nested Queries, Views and Integrity Constraints in easy exam-oriented Hinglish language with examples, important questions and PYQ analysis.

๐Ÿ“˜

Detailed Notes

Learn Relational Model, SQL commands, Relational Algebra, Relational Calculus, Joins, Views and Integrity Constraints with easy explanations and practical examples.

Read Notes
โญ

Important Questions

Prepare important 2 marks, 5 marks, 7 marks and 14 marks questions from SQL, Relational Algebra, Joins and Integrity Constraints.

View Questions
๐Ÿ“„

PYQ Analysis

Check repeated RGPV questions, exam trends and 2026 predictions for DBMS Unit 2.

Open Analysis

DBMS Unit 2 Syllabus Topics

Relational Model Relational Algebra Relational Calculus Introduction to SQL DDL Commands DML Commands DCL Commands TCL Commands SQL Joins Nested Queries Views Integrity Constraints Important Questions PYQ Analysis FAQs

What You Will Learn in DBMS Unit 2?

DBMS Unit 2 is one of the most practical and scoring units in the Database Management System syllabus. In this unit, students learn how data is stored inside tables and how SQL is used to retrieve, insert, update and delete data.

This unit forms the foundation of database programming, web development, backend development and software engineering. Almost every company uses SQL databases, making this unit extremely important for both examinations and placements.

UNIT 2 ROADMAP โ†“ Relational Model โ†“ Relational Algebra โ†“ Relational Calculus โ†“ SQL โ†“ DDL โ†“ DML โ†“ DCL โ†“ TCL โ†“ Joins โ†“ Views โ†“ Integrity Constraints

Relational Algebra

Relational Algebra DBMS ka procedural query language hai. Iska use relational databases par operations perform karne ke liye kiya jata hai.

Relational Algebra SQL ka foundation mana jata hai. SQL ke bahut saare commands Relational Algebra operations par based hote hain.


Definition

Relational Algebra is a procedural query language that uses various operations to retrieve and manipulate data from relational databases.


Why Relational Algebra is Important?


Basic Concept

Table โ†“ Relational Algebra Operation โ†“ Result Table

Input bhi relation hota hai aur output bhi relation hota hai.


Types of Operations

Relational Algebra โ”‚ โ”œโ”€โ”€ Selection (ฯƒ) โ”œโ”€โ”€ Projection (ฯ€) โ”œโ”€โ”€ Union (โˆช) โ”œโ”€โ”€ Set Difference (-) โ”œโ”€โ”€ Intersection (โˆฉ) โ”œโ”€โ”€ Cartesian Product (ร—) โ”œโ”€โ”€ Join (โจ) โ””โ”€โ”€ Division (รท)

Student Relation Example

Roll No Name Branch Marks
101 Shivam CSE 85
102 Rahul IT 78
103 Aman CSE 90

1. Selection Operation (ฯƒ)

Selection operation rows ko select karta hai based on a condition.

Symbol

ฯƒ

Example

ฯƒ Branch='CSE' (Student)

Ye query sirf CSE students ko return karegi.


2. Projection Operation (ฯ€)

Projection operation selected columns ko display karta hai.

Symbol

ฯ€

Example

ฯ€ Name, Branch (Student)

Sirf Name aur Branch columns display honge.


3. Union Operation (โˆช)

Union do relations ke tuples ko combine karta hai.

Example

Student_CSE โˆช Student_IT

Result me dono tables ke records aa jayenge.


Conditions for Union


4. Set Difference Operation (-)

Set Difference ek relation ke tuples ko return karta hai jo doosre relation me present nahi hote.

Example

Student - Passed_Students

Result me failed students milenge.


5. Intersection Operation (โˆฉ)

Intersection common tuples return karta hai.

Example

A โˆฉ B

Result me sirf common records aayenge.


6. Cartesian Product (ร—)

Cartesian Product do relations ke sabhi possible combinations generate karta hai.

Example

Student ร— Course

Formula

If Relation A has m rows and Relation B has n rows:

Result Rows = m ร— n

7. Join Operation (โจ)

Join operation do tables ko common attribute ke basis par combine karta hai.

Example

Student โจ Department

Student aur Department tables merge ho jayengi.


Types of Join


8. Division Operation (รท)

Division operation advanced queries ke liye use hota hai.

Ye generally "for all" type questions solve karne me use hota hai.


Example of Division

Find students who have completed all courses.

Student_Course รท Courses

Advantages of Relational Algebra


Disadvantages of Relational Algebra


Summary Table

Operation Symbol Purpose
Selection ฯƒ Select Rows
Projection ฯ€ Select Columns
Union โˆช Combine Tuples
Difference - Remove Common Tuples
Intersection โˆฉ Common Tuples
Cartesian Product ร— All Combinations
Join โจ Combine Tables
Division รท Advanced Queries

Memory Trick

ฯƒ โ†“ Rows ---------------- ฯ€ โ†“ Columns ---------------- โˆช โ†“ Combine ---------------- โˆฉ โ†“ Common ---------------- โจ โ†“ Join Tables

RGPV Exam Keywords


Most Expected Questions

2 Marks

5 Marks

7 Marks

14 Marks

Relational Calculus

Relational Calculus DBMS ka non-procedural query language hai. Relational Algebra me hume batana padta hai ki result kaise obtain karna hai, jabki Relational Calculus me sirf ye batana hota hai ki hume kya result chahiye.

Relational Calculus mathematical predicate logic par based hota hai aur SQL ke development me iska important contribution raha hai.


Definition

Relational Calculus is a non-procedural query language that specifies what data is required without specifying how to retrieve it.


Basic Concept

Relational Algebra โ†“ How to Retrieve Data ------------------------ Relational Calculus โ†“ What Data is Required

Procedural vs Non-Procedural Language

Procedural Language Non-Procedural Language
Specifies HOW Specifies WHAT
Relational Algebra Relational Calculus
Step-by-Step Operations Desired Result Only
More Complex Easier to Write

Types of Relational Calculus

Relational Calculus โ”‚ โ”œโ”€โ”€ Tuple Relational Calculus (TRC) โ””โ”€โ”€ Domain Relational Calculus (DRC)

1. Tuple Relational Calculus (TRC)

Tuple Relational Calculus me variables tuples ko represent karte hain.

Query tuple variables ki help se likhi jati hai.


General Form

{ t | P(t) }

Where:


Example

Find all students having marks greater than 80.

{ t | Student(t) AND t.Marks > 80 }

Student Relation

Roll No Name Marks
101 Shivam 85
102 Rahul 70
103 Aman 90

Result:

Shivam Aman

Advantages of TRC


2. Domain Relational Calculus (DRC)

Domain Relational Calculus me variables attribute values ko represent karte hain.

Tuple ki jagah individual attribute values use ki jati hain.


General Form

{ | P(x1,x2,x3...) }

Example

Find names of students having marks greater than 80.

{ | Student(RollNo, Name, Marks) AND Marks > 80 }

TRC vs DRC

TRC DRC
Uses Tuple Variables Uses Domain Variables
Tuple Based Attribute Based
Easier Representation Detailed Representation
Entire Tuple Considered Individual Attributes Considered

Free Variables

Free Variable wo variable hota hai jo query result me appear karta hai.

Ye result generate karne ke liye use hota hai.


Bound Variables

Bound Variable logical quantifiers ke under define kiya jata hai.

Ye query evaluation ke liye use hota hai.


Quantifiers in Relational Calculus

Quantifiers โ”‚ โ”œโ”€โ”€ Universal Quantifier (โˆ€) โ””โ”€โ”€ Existential Quantifier (โˆƒ)

Universal Quantifier (โˆ€)

Universal Quantifier ka meaning hota hai "For All".

Example:

All students passed the exam.

โˆ€ Student

Existential Quantifier (โˆƒ)

Existential Quantifier ka meaning hota hai "There Exists".

Example:

There exists a student whose marks are greater than 90.

โˆƒ Student

Advantages of Relational Calculus


Disadvantages of Relational Calculus


Relational Algebra vs Relational Calculus

Relational Algebra Relational Calculus
Procedural Non-Procedural
Specifies HOW Specifies WHAT
Operation Based Predicate Logic Based
More Detailed More Abstract
Uses Operators Uses Quantifiers

Memory Trick

TRC โ†“ Tuple ------------------- DRC โ†“ Domain ------------------- Algebra โ†“ HOW ------------------- Calculus โ†“ WHAT

RGPV Exam Keywords


Most Expected Questions

2 Marks

5 Marks

7 Marks

14 Marks

Introduction to SQL

SQL (Structured Query Language) DBMS ki sabse important language hai. SQL ka use database ko create, manage, modify aur retrieve karne ke liye kiya jata hai.

Aaj ke modern databases jaise MySQL, Oracle, PostgreSQL, MariaDB aur SQL Server sab SQL support karte hain.

RGPV exams me SQL se direct 7 marks aur 14 marks ke questions frequently pooche jate hain.


Definition

SQL (Structured Query Language) is a standard database language used to create, retrieve, update and manage data in relational databases.


Why SQL is Needed?


Basic Concept of SQL

User โ†“ SQL Query โ†“ DBMS โ†“ Database โ†“ Result

History of SQL

SQL IBM ke researchers ne develop ki thi.

Ye Relational Model ke creator Dr. E. F. Codd ke concepts par based hai.

SQL ko ANSI aur ISO standards ne adopt kiya hai.


Features of SQL


Applications of SQL


Components of SQL

SQL โ”‚ โ”œโ”€โ”€ DDL โ”œโ”€โ”€ DML โ”œโ”€โ”€ DCL โ””โ”€โ”€ TCL

1. DDL (Data Definition Language)

DDL database structure define karne ke liye use hoti hai.

Commands:


2. DML (Data Manipulation Language)

DML data insert, update aur delete karne ke liye use hoti hai.

Commands:


3. DCL (Data Control Language)

DCL database security aur permissions manage karti hai.

Commands:


4. TCL (Transaction Control Language)

TCL transactions ko manage karti hai.

Commands:


SQL Architecture

Application โ†“ SQL Query โ†“ DBMS Engine โ†“ Database

Example Database

Roll_No Name Branch Marks
101 Shivam CSE 85
102 Rahul IT 78

Example SQL Query

SELECT * FROM Student;

Ye query Student table ke sabhi records display karegi.


SQL Processing Steps

Write Query โ†“ Parse Query โ†“ Optimize Query โ†“ Execute Query โ†“ Display Result

Advantages of SQL


Disadvantages of SQL


Real Life Example

Suppose College Database me 5000 students hain.

Agar hume CSE students ki list chahiye to SQL query use kar sakte hain:

SELECT * FROM Student WHERE Branch='CSE';

Ye query sirf CSE students display karegi.


SQL vs Relational Algebra

SQL Relational Algebra
Practical Language Theoretical Language
Used by Developers Used for Concepts
User Friendly Mathematical
Industry Standard Foundation of SQL

Memory Trick

SQL โ†“ Create Store Retrieve Update Delete

Exam Shortcut

DDL โ†“ Structure ---------------- DML โ†“ Data ---------------- DCL โ†“ Security ---------------- TCL โ†“ Transactions

RGPV Exam Keywords


Most Expected Questions

2 Marks

5 Marks

7 Marks

14 Marks

DDL Commands (Data Definition Language)

DDL (Data Definition Language) SQL ka wo part hai jo database ki structure ko define aur modify karne ke liye use hota hai.

DDL commands tables, databases aur schemas ko create, alter aur delete karne ke liye use ki jati hain.


Definition

DDL (Data Definition Language) is a set of SQL commands used to define, modify and manage database structures.


Purpose of DDL


DDL Commands List

DDL Commands โ”‚ โ”œโ”€โ”€ CREATE โ”œโ”€โ”€ ALTER โ”œโ”€โ”€ DROP โ””โ”€โ”€ TRUNCATE

1. CREATE Command

CREATE command ka use database ya table create karne ke liye hota hai.


Syntax

CREATE TABLE Student ( Roll_No INT, Name VARCHAR(50), Branch VARCHAR(20), Marks INT );

Example

CREATE TABLE Student ( Roll_No INT PRIMARY KEY, Name VARCHAR(50), Branch VARCHAR(20) );

Result

Roll_No Name Branch

Student table successfully create ho jayegi.


2. ALTER Command

ALTER command existing table ki structure ko modify karne ke liye use hoti hai.


Add Column

ALTER TABLE Student ADD Marks INT;

Result

Roll_No Name Branch Marks

Modify Column

ALTER TABLE Student MODIFY Name VARCHAR(100);

Drop Column

ALTER TABLE Student DROP COLUMN Marks;

3. DROP Command

DROP command database object ko permanently delete kar deta hai.

Delete hone ke baad data recover nahi hota.


Syntax

DROP TABLE Student;

Effect

Table Structure โŒ Deleted ------------------- Data โŒ Deleted

4. TRUNCATE Command

TRUNCATE command table ke saare records remove kar deta hai lekin table structure ko preserve rakhta hai.


Syntax

TRUNCATE TABLE Student;

Before TRUNCATE

Roll No Name
101 Shivam
102 Rahul

After TRUNCATE

Roll No Name

Table empty ho jayegi lekin structure exist karega.


CREATE vs ALTER vs DROP vs TRUNCATE

Command Purpose
CREATE Create New Table
ALTER Modify Table Structure
DROP Delete Table + Structure
TRUNCATE Delete Data Only

DROP vs TRUNCATE

DROP TRUNCATE
Deletes Structure Keeps Structure
Deletes Data Deletes Data
Cannot Reuse Table Can Reuse Table
Permanent Removal Only Records Removed

Real Life Example

Suppose College Database me Student table create karni hai:

CREATE TABLE Student โ†“ ADD Marks โ†“ MODIFY Name โ†“ TRUNCATE Records โ†“ DROP Table

Advantages of DDL


Memory Trick

CREATE โ†“ Create Table ------------------- ALTER โ†“ Change Table ------------------- DROP โ†“ Delete Table ------------------- TRUNCATE โ†“ Delete Data

Exam Shortcut

Command Remember
CREATE New Table
ALTER Modify Structure
DROP Remove Table
TRUNCATE Remove Records

RGPV Exam Keywords


Most Expected Questions

2 Marks

5 Marks

7 Marks

14 Marks

DML Commands (Data Manipulation Language)

DML (Data Manipulation Language) SQL ka important part hai jo database ke andar stored data ko manipulate karne ke liye use hota hai.

DDL database structure ko manage karti hai, jabki DML actual records par operations perform karti hai.


Definition

DML (Data Manipulation Language) is a set of SQL commands used to insert, retrieve, update and delete data from database tables.


Purpose of DML


DML Commands

DML Commands โ”‚ โ”œโ”€โ”€ INSERT โ”œโ”€โ”€ SELECT โ”œโ”€โ”€ UPDATE โ””โ”€โ”€ DELETE

Student Table Example

Roll_No Name Branch Marks

1. INSERT Command

INSERT command table me new records add karne ke liye use hoti hai.


Syntax

INSERT INTO Student VALUES (101,'Shivam','CSE',85);

Example

INSERT INTO Student VALUES (102,'Rahul','IT',78);

Result

Roll_No Name Branch Marks
101 Shivam CSE 85
102 Rahul IT 78

2. SELECT Command

SELECT command database se data retrieve karne ke liye use hoti hai.

Ye SQL ki sabse frequently used command hai.


Syntax

SELECT * FROM Student;

Result

Student table ke sabhi records display honge.


Specific Columns Select Karna

SELECT Name, Marks FROM Student;

WHERE Clause

WHERE clause specific condition apply karne ke liye use hota hai.


Example

SELECT * FROM Student WHERE Branch='CSE';

Result

Sirf CSE students display honge.


Comparison Operators

Operator Meaning
= Equal To
> Greater Than
< Less Than
>= Greater Than Equal
<= Less Than Equal
!= Not Equal

Example Queries

SELECT * FROM Student WHERE Marks > 80;

SELECT Name FROM Student WHERE Branch='IT';

3. UPDATE Command

UPDATE command existing records ko modify karne ke liye use hoti hai.


Syntax

UPDATE Student SET Marks = 90 WHERE Roll_No = 101;

Before Update

Roll_No Name Marks
101 Shivam 85

After Update

Roll_No Name Marks
101 Shivam 90

4. DELETE Command

DELETE command table se records remove karne ke liye use hoti hai.


Syntax

DELETE FROM Student WHERE Roll_No = 102;

Result

Roll Number 102 wala record delete ho jayega.


Delete All Records

DELETE FROM Student;

Table ke saare records delete ho jayenge lekin structure rahega.


SELECT vs DELETE vs UPDATE

Command Purpose
SELECT Retrieve Data
UPDATE Modify Data
DELETE Remove Data

INSERT vs UPDATE

INSERT UPDATE
Add New Record Modify Existing Record
Creates New Row Changes Existing Row

Real Life Example

Admission โ†“ INSERT Student ------------------- View Result โ†“ SELECT Student ------------------- Correction โ†“ UPDATE Student ------------------- Remove Record โ†“ DELETE Student

Advantages of DML


Memory Trick

INSERT โ†“ Add Data ----------------- SELECT โ†“ View Data ----------------- UPDATE โ†“ Modify Data ----------------- DELETE โ†“ Remove Data

Exam Shortcut

Command Remember
INSERT Add Record
SELECT Show Record
UPDATE Change Record
DELETE Remove Record

RGPV Exam Keywords


Most Expected Questions

2 Marks

5 Marks

7 Marks

14 Marks

DCL Commands (Data Control Language)

DCL (Data Control Language) SQL ka wo part hai jo database security aur user permissions ko manage karta hai.

DCL commands determine karti hain ki kaun user database ke kis part ko access kar sakta hai.


Definition

DCL (Data Control Language) is a set of SQL commands used to control access permissions and security in a database.


Why DCL is Needed?


DCL Commands

DCL โ”‚ โ”œโ”€โ”€ GRANT โ””โ”€โ”€ REVOKE

1. GRANT Command

GRANT command kisi user ko database permissions dene ke liye use hoti hai.


Syntax

GRANT Permission ON Table_Name TO User_Name;

Example

GRANT SELECT ON Student TO Rahul;

Meaning

Rahul user ab Student table ko read kar sakta hai.


Multiple Permissions Example

GRANT SELECT, INSERT, UPDATE ON Student TO Rahul;

2. REVOKE Command

REVOKE command previously granted permissions ko remove karne ke liye use hoti hai.


Syntax

REVOKE Permission ON Table_Name FROM User_Name;

Example

REVOKE SELECT ON Student FROM Rahul;

Meaning

Rahul ab Student table ko access nahi kar sakta.


GRANT vs REVOKE

GRANT REVOKE
Provides Permission Removes Permission
Access Allow Access Deny
Security Setup Security Removal

Real Life Example

Admin โ†“ GRANT Access โ†“ Faculty ------------------- Admin โ†“ REVOKE Access โ†“ Faculty

TCL Commands (Transaction Control Language)

TCL (Transaction Control Language) transactions ko manage karne ke liye use hoti hai.

Transaction ka matlab database operations ka group hota hai jo ek unit ki tarah execute hota hai.


Definition

TCL (Transaction Control Language) is a set of SQL commands used to manage database transactions.


What is a Transaction?

Transaction database operations ka logical unit hota hai.

Example:

Bank Account Transfer

Account A โ†“ Withdraw โ‚น1000 โ†“ Account B โ†“ Deposit โ‚น1000

Ye complete process ek transaction hai.


TCL Commands

TCL โ”‚ โ”œโ”€โ”€ COMMIT โ”œโ”€โ”€ ROLLBACK โ””โ”€โ”€ SAVEPOINT

1. COMMIT Command

COMMIT command transaction ko permanently save kar deta hai.


Syntax

COMMIT;

Example

UPDATE Student SET Marks = 90 WHERE Roll_No = 101; COMMIT;

Result

Changes permanently database me save ho jayenge.


2. ROLLBACK Command

ROLLBACK command transaction ko undo kar deta hai.


Syntax

ROLLBACK;

Example

UPDATE Student SET Marks = 50 WHERE Roll_No = 101; ROLLBACK;

Result

Database previous state me wapas aa jayega.


3. SAVEPOINT Command

SAVEPOINT transaction ke andar temporary checkpoint create karta hai.


Syntax

SAVEPOINT SP1;

Example

UPDATE Student SET Marks = 90 WHERE Roll_No = 101; SAVEPOINT SP1; UPDATE Student SET Marks = 95 WHERE Roll_No = 101;

Rollback to Savepoint

ROLLBACK TO SP1;

Database SP1 state tak return ho jayega.


Transaction Flow

Start Transaction โ†“ Execute Query โ†“ SAVEPOINT โ†“ More Operations โ†“ COMMIT OR ROLLBACK

COMMIT vs ROLLBACK

COMMIT ROLLBACK
Save Changes Undo Changes
Permanent Temporary Undo
Transaction Success Transaction Failure

Advantages of TCL


Memory Trick

GRANT โ†“ Give Permission ------------------- REVOKE โ†“ Remove Permission ------------------- COMMIT โ†“ Save Changes ------------------- ROLLBACK โ†“ Undo Changes ------------------- SAVEPOINT โ†“ Checkpoint

Exam Shortcut

Command Purpose
GRANT Allow Access
REVOKE Remove Access
COMMIT Save Transaction
ROLLBACK Undo Transaction
SAVEPOINT Create Checkpoint

RGPV Exam Keywords


Most Expected Questions

2 Marks

5 Marks

7 Marks

14 Marks

SQL Joins

SQL Join ka use do ya do se adhik tables ko common field ke basis par connect karne ke liye kiya jata hai.

Real-world databases me data multiple tables me store hota hai. Isliye information retrieve karne ke liye Joins ka use bahut important hota hai.

RGPV exams me SQL Joins se frequently 7 marks aur 14 marks ke questions pooche jate hain.


Definition

A Join is an SQL operation used to combine rows from two or more tables based on a related column between them.


Why Joins are Needed?


Example Tables

Student Table

Roll_No Name Dept_ID
101 Shivam D1
102 Rahul D2
103 Aman D1

Department Table

Dept_ID Department
D1 CSE
D2 IT

Types of SQL Joins

SQL Joins โ”‚ โ”œโ”€โ”€ Inner Join โ”œโ”€โ”€ Left Join โ”œโ”€โ”€ Right Join โ”œโ”€โ”€ Full Outer Join โ”œโ”€โ”€ Natural Join โ””โ”€โ”€ Self Join

1. Inner Join

Inner Join sirf matching records return karta hai.


Syntax

SELECT * FROM Student INNER JOIN Department ON Student.Dept_ID = Department.Dept_ID;

Result

Name Department
Shivam CSE
Rahul IT
Aman CSE

Inner Join Diagram

Table A โ—ฏโ—ฏโ—‰ โ—‰ = Common Records โ—‰โ—ฏโ—ฏ Table B

2. Left Join (Left Outer Join)

Left Join left table ke saare records return karta hai aur matching records right table se lata hai.


Syntax

SELECT * FROM Student LEFT JOIN Department ON Student.Dept_ID = Department.Dept_ID;

Result

Student table ke saare records display honge chahe Department match kare ya nahi.


Left Join Diagram

โ—‰โ—‰โ—‰โ—‰ โ—‰โ—‰ Left Table Priority

3. Right Join (Right Outer Join)

Right Join right table ke saare records return karta hai aur matching records left table se lata hai.


Syntax

SELECT * FROM Student RIGHT JOIN Department ON Student.Dept_ID = Department.Dept_ID;

Right Join Diagram

โ—‰โ—‰ โ—‰โ—‰โ—‰โ—‰ Right Table Priority

4. Full Outer Join

Full Outer Join dono tables ke saare records return karta hai.

Matching aur non-matching dono records include hote hain.


Syntax

SELECT * FROM Student FULL OUTER JOIN Department ON Student.Dept_ID = Department.Dept_ID;

Diagram

Entire Table A + Entire Table B

5. Natural Join

Natural Join automatically same name wale columns ke basis par join perform karta hai.


Syntax

SELECT * FROM Student NATURAL JOIN Department;

Advantage

ON condition explicitly likhne ki zarurat nahi hoti.


6. Self Join

Self Join me table khud ke saath join hoti hai.


Example

Employee aur Manager relationship.

Employee โ†“ Manager โ†“ Employee

Syntax

SELECT E1.Name, E2.Name FROM Employee E1, Employee E2 WHERE E1.Manager_ID = E2.Employee_ID;

Join Operation Working

Table A + Table B โ†“ Common Column โ†“ Join Condition โ†“ Combined Result

Inner Join vs Outer Join

Inner Join Outer Join
Only Matching Rows Matching + Non-Matching Rows
Smaller Result Larger Result
Most Common Special Cases

Left Join vs Right Join

Left Join Right Join
All Left Records All Right Records
Left Table Priority Right Table Priority

Advantages of Joins


Memory Trick

INNER โ†“ Only Match ------------------- LEFT โ†“ All Left ------------------- RIGHT โ†“ All Right ------------------- FULL โ†“ All Records ------------------- SELF โ†“ Same Table

Exam Shortcut

Join Remember
Inner Join Common Records
Left Join All Left Records
Right Join All Right Records
Full Join Everything
Self Join Same Table

RGPV Exam Keywords


Most Expected Questions

2 Marks

5 Marks

7 Marks

14 Marks

Nested Queries (Subqueries)

Nested Query ya Subquery ek query ke andar likhi gayi doosri query hoti hai.

Jab kisi query ka result doosri query me use hota hai, tab Nested Query ka use kiya jata hai.

RGPV exams me Nested Queries se frequently programming aur theory based questions pooche jate hain.


Definition

A Nested Query is a query embedded inside another SQL query.


Basic Structure

Outer Query โ†“ (Sub Query) โ†“ Result

Student Table

Roll_No Name Marks
101 Shivam 85
102 Rahul 70
103 Aman 90

Example 1

Find students having marks greater than average marks.

SELECT Name FROM Student WHERE Marks > ( SELECT AVG(Marks) FROM Student );

Working

Subquery Executes First โ†“ AVG(Marks) โ†“ 81.67 โ†“ Outer Query Executes

Example 2

Find student having maximum marks.

SELECT * FROM Student WHERE Marks = ( SELECT MAX(Marks) FROM Student );

Types of Nested Queries

Nested Queries โ”‚ โ”œโ”€โ”€ Single Row Subquery โ”œโ”€โ”€ Multiple Row Subquery โ”œโ”€โ”€ Correlated Subquery โ””โ”€โ”€ Nested Subquery

1. Single Row Subquery

Single Row Subquery sirf ek value return karti hai.

Example

SELECT * FROM Student WHERE Marks > ( SELECT AVG(Marks) FROM Student );

2. Multiple Row Subquery

Multiple Row Subquery multiple values return karti hai.

Example

SELECT * FROM Student WHERE Branch IN ( SELECT Branch FROM Department );

3. Correlated Subquery

Correlated Subquery outer query par depend karti hai.

Ye har row ke liye execute hoti hai.


Example

SELECT S1.Name FROM Student S1 WHERE Marks > ( SELECT AVG(Marks) FROM Student S2 WHERE S1.Branch = S2.Branch );

Advantages of Nested Queries


Disadvantages of Nested Queries


Views

View ek virtual table hoti hai jo actual table ke data par based hoti hai.

View khud data store nahi karti. Ye sirf query ka result store karti hai.


Definition

A View is a virtual table created from one or more database tables using an SQL query.


Why Views are Needed?


View Architecture

User โ†“ View โ†“ Actual Table

Create View

Syntax

CREATE VIEW CSE_Students AS SELECT * FROM Student WHERE Branch='CSE';

Using a View

SELECT * FROM CSE_Students;

Example

Roll_No Name Branch
101 Shivam CSE
103 Aman CSE

Ye view sirf CSE students ko show karegi.


Drop View

Syntax

DROP VIEW CSE_Students;

Advantages of Views


Disadvantages of Views


View vs Table

View Table
Virtual Physical
No Data Storage Stores Data
Query Based Actual Records
Security Purpose Data Storage Purpose

Nested Query vs View

Nested Query View
Query Inside Query Virtual Table
Temporary Result Reusable Result
Used During Execution Stored Definition

Memory Trick

Nested Query โ†“ Query Inside Query ------------------- View โ†“ Virtual Table ------------------- Subquery โ†“ Runs First

Exam Shortcut

Concept Remember
Nested Query Query Inside Query
View Virtual Table
CREATE VIEW Create Virtual Table
DROP VIEW Delete View

RGPV Exam Keywords


Most Expected Questions

2 Marks

5 Marks

7 Marks

14 Marks

Integrity Constraints

Integrity Constraints DBMS ke rules hote hain jo database me data ki accuracy, consistency aur reliability maintain karte hain.

Agar Integrity Constraints na ho to database me invalid, duplicate aur inconsistent data store ho sakta hai.

RGPV examinations me Integrity Constraints se frequently 5 marks, 7 marks aur 14 marks ke questions pooche jate hain.


Definition

Integrity Constraints are rules applied on database tables to ensure the correctness, consistency and validity of data.


Why Integrity Constraints are Needed?


Types of Integrity Constraints

Integrity Constraints โ”‚ โ”œโ”€โ”€ Domain Constraint โ”œโ”€โ”€ Key Constraint โ”œโ”€โ”€ Entity Integrity Constraint โ”œโ”€โ”€ Referential Integrity Constraint โ””โ”€โ”€ NOT NULL Constraint

1. Domain Constraint

Domain Constraint ensure karta hai ki attribute ki value predefined domain ke andar hi ho.


Example

Marks โ†“ 0 to 100

Agar koi student ke marks 150 enter kare to Domain Constraint violation hoga.


Valid Values

Marks = 85 Marks = 92 Marks = 75

Invalid Values

Marks = -10 Marks = 150

2. Key Constraint

Key Constraint ensure karta hai ki Primary Key unique ho.

Do records ki Primary Key same nahi ho sakti.


Example

Roll_No Name
101 Shivam
102 Rahul

Yahaan Roll_No unique hai.


Invalid Example

Roll_No Name
101 Shivam
101 Rahul

Ye Key Constraint violation hai.


3. Entity Integrity Constraint

Entity Integrity ke according Primary Key kabhi NULL nahi ho sakti.


Rule

Primary Key โ‰  NULL

Valid Example

Roll_No Name
101 Shivam

Invalid Example

Roll_No Name
NULL Shivam

Primary Key NULL nahi ho sakti.


4. Referential Integrity Constraint

Referential Integrity Foreign Key aur Primary Key ke relationship ko maintain karti hai.


Rule

Foreign Key value ya to referenced table me exist karegi ya NULL hogi.


Department Table

Dept_ID Department
D1 CSE
D2 IT

Student Table

Roll_No Name Dept_ID
101 Shivam D1
102 Rahul D2

Valid Foreign Keys

D1 D2

Invalid Foreign Key

D5

Department table me D5 exist nahi karta.

Ye Referential Integrity violation hai.


5. NOT NULL Constraint

NOT NULL Constraint ensure karta hai ki attribute empty na ho.


Example

Name NOT NULL

Valid

Name = Shivam

Invalid

Name = NULL

SQL Example

CREATE TABLE Student ( Roll_No INT PRIMARY KEY, Name VARCHAR(50) NOT NULL, Marks INT CHECK(Marks <=100) );

Constraint Summary

Constraint Purpose
Domain Constraint Valid Values Only
Key Constraint Unique Records
Entity Integrity Primary Key Not NULL
Referential Integrity Valid Foreign Key
NOT NULL No Empty Values

Advantages of Integrity Constraints


Real Life Example

College Database โ†“ Roll Number Must Be Unique โ†“ Entity Integrity --------------------- Department ID Must Exist โ†“ Referential Integrity --------------------- Marks 0 to 100 โ†“ Domain Constraint

Memory Trick

Domain โ†“ Valid Values ------------------ Key โ†“ Unique Values ------------------ Entity โ†“ Primary Key Not Null ------------------ Referential โ†“ Valid Foreign Key

Exam Shortcut

Constraint Remember
Domain Range Check
Key Unique
Entity Primary Key โ‰  NULL
Referential Foreign Key Valid

RGPV Exam Keywords


Most Expected Questions

2 Marks

5 Marks

7 Marks

14 Marks

DBMS Unit 2 Important Questions

The following questions are selected based on RGPV previous year examination patterns, repeated university questions and expected topics for upcoming examinations.


๐Ÿ”ฅ Top Important 2 Marks Questions

Define Relational Model.
What is a Tuple?
What is an Attribute?
Define Relational Algebra.
What is SQL?
Define DDL.
Define DML.
What is DCL?
What is TCL?
What is a View?
What is Referential Integrity?
What is Inner Join?

โญ Top Important 5 Marks Questions

Explain Relational Model with example.
Explain Selection and Projection operations.
Differentiate Relational Algebra and Relational Calculus.
Explain SQL architecture.
Explain DDL commands with examples.
Explain DML commands with examples.
Explain GRANT and REVOKE commands.
Explain COMMIT and ROLLBACK.
Explain SQL Joins.
Explain Views in DBMS.

๐Ÿ† Top Important 7 Marks Questions

Explain Relational Model and its terminology.
Explain Relational Algebra operations with examples.
Explain Tuple Relational Calculus and Domain Relational Calculus.
Discuss SQL and its components.
Explain DDL and DML commands with syntax.
Explain DCL and TCL commands.
Explain different types of SQL Joins.
Explain Nested Queries with examples.
Explain Integrity Constraints.
Differentiate View and Table.

๐Ÿš€ Most Important 14 Marks Questions

Explain Relational Model in detail with keys and examples.
Explain Relational Algebra operations with suitable examples.
Explain Relational Calculus and its types.
Explain SQL and its components with examples.
Explain DDL, DML, DCL and TCL commands.
Explain SQL Joins with syntax and examples.
Explain Nested Queries and Views.
Explain Integrity Constraints with examples.

DBMS Unit 2 PYQ Analysis

The following analysis is based on RGPV Previous Year Question Papers (2020, 2022, 2023 and 2025). These topics have appeared repeatedly in university examinations and are highly important for upcoming exams.


Topics Covered

Relational Model
Relational Algebra
SQL
SQL Joins
Nested Queries
Views
Integrity Constraints

PYQ Frequency Analysis

Topic 2020 2022 2023 2025 Frequency
Relational Algebra โœ… โœ… โœ… โœ… โ˜…โ˜…โ˜…โ˜…โ˜…
SQL Queries โœ… โœ… โœ… โœ… โ˜…โ˜…โ˜…โ˜…โ˜…
SQL Joins โŒ โœ… โœ… โœ… โ˜…โ˜…โ˜…โ˜…โ˜…
Referential Integrity โŒ โœ… โœ… โŒ โ˜…โ˜…โ˜…โ˜…โ˜†
Views โŒ โŒ โŒ Short Note โ˜…โ˜…โ˜…โ˜†โ˜†
Relational Model โŒ SQL Based SQL Based SQL Based โ˜…โ˜…โ˜…โ˜…โ˜†

Most Repeated Unit 2 Questions

๐Ÿ”ฅ Q1. Write Relational Algebra Expressions

Appeared In:

Prediction: โญโญโญโญโญ


๐Ÿ”ฅ Q2. Write SQL Queries for Given Database

Appeared In:

Prediction: โญโญโญโญโญ


๐Ÿ”ฅ Q3. Explain Foreign Key and Referential Integrity

Appeared In:

Prediction: โญโญโญโญโญ


๐Ÿ”ฅ Q4. Natural Join / Outer Join Questions

Appeared In:

Prediction: โญโญโญโญโญ


๐Ÿ”ฅ Q5. Views in DBMS

Appeared In:

Prediction: โญโญโญโญโ˜†


2026 Expected Questions

VERY HIGH PROBABILITY ๐Ÿ”ฅ Relational Algebra Operations ๐Ÿ”ฅ SQL Queries ๐Ÿ”ฅ SQL Joins ๐Ÿ”ฅ Referential Integrity ๐Ÿ”ฅ Relational Schema Based Questions -------------------------------- HIGH PROBABILITY โญ Views โญ Nested Queries โญ DDL Commands โญ DML Commands โญ Integrity Constraints

Actual RGPV Trend

If questions are asked from Unit 2, the following topics have appeared most frequently in RGPV examinations:

1. SQL Queries 2. Relational Algebra 3. SQL Joins 4. Referential Integrity 5. Relational Schema Problems

These five topics have appeared in almost every previous year paper either directly or indirectly.


Unit 2 Weightage Analysis

Topic Importance
SQL Queries โ˜…โ˜…โ˜…โ˜…โ˜…
Relational Algebra โ˜…โ˜…โ˜…โ˜…โ˜…
SQL Joins โ˜…โ˜…โ˜…โ˜…โ˜…
Referential Integrity โ˜…โ˜…โ˜…โ˜…โ˜…
Relational Schema Problems โ˜…โ˜…โ˜…โ˜…โ˜…
Nested Queries โ˜…โ˜…โ˜…โ˜…โ˜†
Views โ˜…โ˜…โ˜…โ˜…โ˜†
DDL & DML Commands โ˜…โ˜…โ˜…โ˜…โ˜†
Integrity Constraints โ˜…โ˜…โ˜…โ˜…โ˜†
Relational Model โ˜…โ˜…โ˜…โ˜…โ˜†

2026 Score Booster Topics

โœ“ Relational Algebra โœ“ SQL Queries โœ“ SQL Joins โœ“ Referential Integrity โœ“ Relational Schema Problems โœ“ Nested Queries โœ“ Views โœ“ Integrity Constraints

If you prepare these topics thoroughly, you can cover approximately 75-85% of the repeated RGPV Unit 2 question pattern.

Frequently Asked Questions (FAQs)


What is Relational Model?

Relational Model is a database model in which data is stored in the form of tables called relations.


What is Relational Algebra?

Relational Algebra is a procedural query language used to retrieve and manipulate data from relational databases.


What is Relational Calculus?

Relational Calculus is a non-procedural query language that specifies what data is required rather than how to retrieve it.


What is SQL?

SQL (Structured Query Language) is a standard language used to create, retrieve, update and manage data in relational databases.


What is a Join?

A Join is an SQL operation used to combine records from two or more tables based on a common field.


What is a View?

A View is a virtual table created from one or more database tables using an SQL query.


What is a Nested Query?

A Nested Query or Subquery is a query written inside another SQL query.


What are Integrity Constraints?

Integrity Constraints are rules used to maintain accuracy, consistency and reliability of database data.


What is Entity Integrity?

Entity Integrity ensures that the Primary Key can never contain NULL values.


What is Referential Integrity?

Referential Integrity ensures that every Foreign Key value refers to a valid Primary Key value.

DBMS Unit 2 Quick Revision Sheet

RELATIONAL MODEL โ†“ Relation = Table Tuple = Row Attribute = Column Domain = Allowed Values Degree = Number of Columns Cardinality = Number of Rows -------------------------------- RELATIONAL ALGEBRA โ†“ Selection (ฯƒ) Projection (ฯ€) Union (โˆช) Intersection (โˆฉ) Difference (-) Join (โจ) Cartesian Product (ร—) -------------------------------- RELATIONAL CALCULUS โ†“ TRC DRC Non-Procedural Language -------------------------------- SQL โ†“ DDL DML DCL TCL -------------------------------- DDL โ†“ CREATE ALTER DROP TRUNCATE -------------------------------- DML โ†“ INSERT SELECT UPDATE DELETE -------------------------------- DCL โ†“ GRANT REVOKE -------------------------------- TCL โ†“ COMMIT ROLLBACK SAVEPOINT -------------------------------- JOINS โ†“ Inner Join Left Join Right Join Full Join Natural Join Self Join -------------------------------- INTEGRITY CONSTRAINTS โ†“ Domain Constraint Key Constraint Entity Integrity Referential Integrity NOT NULL

Last Minute Exam Revision

Topic Priority
Relational Algebra โ˜…โ˜…โ˜…โ˜…โ˜…
SQL Commands โ˜…โ˜…โ˜…โ˜…โ˜…
SQL Joins โ˜…โ˜…โ˜…โ˜…โ˜…
Integrity Constraints โ˜…โ˜…โ˜…โ˜…โ˜…
Relational Model โ˜…โ˜…โ˜…โ˜…โ˜…
Views โ˜…โ˜…โ˜…โ˜…โ˜†
Nested Queries โ˜…โ˜…โ˜…โ˜…โ˜†
DCL & TCL โ˜…โ˜…โ˜…โ˜…โ˜†
Relational Calculus โ˜…โ˜…โ˜…โ˜…โ˜†

Most Important Definitions for Exam

Relational Model โ†“ Data Stored in Tables -------------------------------- Relational Algebra โ†“ Procedural Query Language -------------------------------- Relational Calculus โ†“ Non-Procedural Query Language -------------------------------- SQL โ†“ Structured Query Language -------------------------------- Join โ†“ Combine Tables -------------------------------- View โ†“ Virtual Table -------------------------------- Entity Integrity โ†“ Primary Key Cannot Be NULL -------------------------------- Referential Integrity โ†“ Valid Foreign Key

Related DBMS Units

DBMS Unit 1 DBMS Unit 3 DBMS Unit 4 DBMS Unit 5

Conclusion

DBMS Unit 2 introduces students to the practical implementation of relational databases. In this unit we studied Relational Model, Relational Algebra, Relational Calculus, SQL Commands, Joins, Nested Queries, Views and Integrity Constraints.

These concepts form the foundation of database programming and are extensively used in web development, software engineering, backend development and enterprise database systems.

๐Ÿ† UNIT 2 SCORE BOOSTER Must Prepare: โœ“ Relational Model โœ“ Relational Algebra โœ“ SQL Commands โœ“ SQL Joins โœ“ Integrity Constraints โœ“ Views These topics cover most of the repeatedly asked RGPV examination questions.