INFORMATION TECHNOLOGY — CLASS 11
DATABASE & SQL
Complete Chapter Notes — RDBMS + MySQL
Easy English explanations | Hinglish concept boxes | SQL syntax + examples
💡 Concept Samjho (Hinglish):
Ye notes tumhe Database aur SQL ka poora basic clear karne ke liye bane hain — Database kya hota hai se
lekar CREATE DATABASE, CREATE TABLE, aur data manipulation tak sab kuch. Har topic ke baad
Hinglish box hai jo concept ko simple bhasha mein samjhayega.
1. Introduction to Database
1.1 What is Data and Database?
Data means raw facts and figures (like names, numbers, dates) which have no meaning by themselves until
organized. A database is an organized collection of related data, stored and accessed electronically, so that it can
be easily managed, updated, and retrieved.
• Example: A school database may store data about students, teachers, classes, and marks
• A database allows storing large amounts of data in a structured, easy-to-access way
1.2 What is DBMS?
A Database Management System (DBMS) is software used to create, store, manage, and manipulate databases. It
acts as an interface between the user and the database, allowing users to insert, update, delete, and retrieve data
safely and efficiently.
• Examples of DBMS: MySQL, Oracle, MS Access, SQLite, PostgreSQL
1.3 What is RDBMS?
A Relational Database Management System (RDBMS) is a type of DBMS that stores data in the form of tables
(rows and columns), where relationships can be created between different tables. Most modern databases,
including MySQL, are RDBMS.
1.4 Advantages of DBMS
• Reduces data redundancy (duplicate data) and inconsistency
• Provides data security through user permissions and passwords
• Allows multiple users to access data at the same time
• Maintains data integrity through rules and constraints
• Makes searching, sorting, and updating data fast and easy
💡 Concept Samjho (Hinglish):
Simple bhasha mein: Data matlab raw information (jaise names, numbers), aur Database ek organized jagah
hai jaha ye data systematically store hota hai — jaise ek almari jisme cheezein sahi jagah rakhi ho. DBMS wo
software hai jo is almari ko manage karta hai (jaise MySQL). RDBMS wo DBMS hai jo data ko TABLE (rows
aur columns) ke form mein store karta hai — jaise Excel sheet jaisa, lekin bohot powerful aur alag tables ke
beech relation bana sakta hai.
2. Basic Structure of a Table (Relation)
In RDBMS, data is stored in the form of tables. Each table has a structure made up of the following key terms:
Term Meaning
Table / Relation A collection of related data organized in rows and
columns
Term Meaning
Field / Column / Attribute A single property of the table, e.g., Name, Age, Roll
No
Record / Row / Tuple A single complete entry in the table (one student's
full data)
Degree Total number of columns (fields) in a table
Cardinality Total number of rows (records) in a table
Primary Key A field (or set of fields) that uniquely identifies each
record
💡 Concept Samjho (Hinglish):
Table ko Excel sheet jaisa socho: columns (upar se neeche) = Field/Attribute (jaise 'Name', 'Age'), aur rows
(left se right) = Record (ek student ki puri detail). Degree matlab kitne columns hai, Cardinality matlab kitni
rows hai. Primary Key woh special column hai jo har record ko unique banata hai — jaise Roll Number,
kyunki do students ka roll number same nahi ho sakta.
3. Introduction to SQL
SQL (Structured Query Language) is a standard language used to create, manage, and manipulate relational
databases. It is used to communicate with the database — to create tables, insert data, retrieve data, update data,
and delete data.
3.1 Types of SQL Commands
Category Full Form Purpose Common Commands
DDL Data Definition Defines structure of CREATE, ALTER,
Language database objects DROP
DML Data Manipulation Manages data inside INSERT, UPDATE,
Language tables DELETE
DQL Data Query Language Used to fetch/query data SELECT
TCL Transaction Control Manages transactions COMMIT, ROLLBACK
Language
DCL Data Control Language Controls GRANT, REVOKE
access/permissions
💡 Concept Samjho (Hinglish):
SQL ek language hai jisse hum database se 'baat' karte hain. Isko categories mein baanta gaya hai: DDL se
table ka structure banate/badalte hain (jaise ghar ka naksha), DML se data ko andar daalte/change karte
hain (jaise ghar mein saman rakhna), aur DQL (SELECT) se data ko dekhte/nikaalte hain. Class 11 mein
sabse zyada DDL aur DML hi use hota hai.
4. Creating and Using a Database
4.1 CREATE DATABASE Statement
This command is used to create a new, empty database in the RDBMS (like MySQL).
CREATE DATABASE database_name;
-- Example:
CREATE DATABASE School;
4.2 SHOW DATABASES
This command lists all the databases currently present in the RDBMS system.
SHOW DATABASES;
4.3 USE Statement
Before creating tables or working with data, we must select which database to work in. The USE command
opens/selects a particular database.
USE database_name;
-- Example:
USE School;
4.4 DROP DATABASE
This command permanently deletes an entire database along with all its tables and data. It should be used very
carefully.
DROP DATABASE database_name;
💡 Concept Samjho (Hinglish):
CREATE DATABASE se ek naya khaali database bana lete hain — jaise ek naya folder banana. USE
command se hum batate hain ki 'ab mujhe isi database ke andar kaam karna hai' — jaise us folder ko open
karna. Jab tak USE nahi karoge, MySQL ko pata nahi chalega ki table kaha banani hai. DROP DATABASE
bohot dangerous command hai — isse pura database (sab tables + data) permanently delete ho jaata hai,
wapas nahi aata!
5. Common SQL Data Types
While creating a table, each column must be assigned a data type that defines what kind of value it can store.
Data Type Description Example
INT / INTEGER Whole numbers (no decimals) 25, 100, -5
Data Type Description Example
DECIMAL(m,d) / FLOAT Numbers with decimal points 99.50, 3.14
CHAR(n) Fixed-length text of size n CHAR(2) → 'IN'
VARCHAR(n) Variable-length text, max size n VARCHAR(50) → 'Ali Khan'
DATE Stores date values '2026-08-15'
BOOLEAN Stores TRUE or FALSE TRUE / FALSE
💡 Concept Samjho (Hinglish):
Data type batata hai column mein kis TARAH ka data aayega. INT sirf whole numbers ke liye (jaise Age),
VARCHAR text ke liye (jaise Name) — 'VAR' matlab variable length, yani jitna text hoga utni hi jagah lagegi
(efficient). CHAR fixed length hota hai — chahe text chhota ho, utni hi jagah reserved rehti hai. DATE se
dates store hoti hain format mein 'YYYY-MM-DD'.
6. Creating a Table — CREATE TABLE
Once a database is created and selected (using USE), tables can be created inside it using the CREATE TABLE
statement. Each column is defined with a name and a data type.
6.1 Basic Syntax
CREATE TABLE table_name (
column1 datatype constraint,
column2 datatype constraint,
column3 datatype constraint,
...
);
6.2 Example: Creating a Student Table
CREATE TABLE Student (
RollNo INT PRIMARY KEY,
Name VARCHAR(30) NOT NULL,
Age INT,
Class VARCHAR(10),
Marks DECIMAL(5,2)
);
In the above example, RollNo is set as the PRIMARY KEY (so it must be unique for every student), and Name
has a NOT NULL constraint (so it cannot be left empty).
6.3 Viewing Table Structure
DESC table_name;
-- or --
DESCRIBE table_name;
-- Example:
DESC Student;
6.4 Viewing All Tables in a Database
SHOW TABLES;
💡 Concept Samjho (Hinglish):
CREATE TABLE se hum table ka structure define karte hain — kaunse columns honge aur unka data type kya
hoga, bilkul waise jaise Excel sheet mein columns banate hain lekin yahan rules (constraints) bhi laga sakte
hain. DESC command se pata chalta hai table mein kaunse columns hain aur unke data types kya hain — bina
data dekhe sirf structure check karne ke liye useful hai.
7. Constraints in SQL
Constraints are rules applied to columns of a table to maintain the accuracy and reliability of the data.
Constraint Purpose
PRIMARY KEY Uniquely identifies each record; cannot be NULL or
duplicate
NOT NULL Ensures a column cannot have an empty (NULL)
value
UNIQUE Ensures all values in a column are different
DEFAULT Sets a default value if none is provided
CHECK Restricts values based on a condition, e.g., Age > 0
FOREIGN KEY Links a column to the primary key of another table
💡 Concept Samjho (Hinglish):
Constraints matlab table par lagaye gaye rules jo galat data ko rokte hain. PRIMARY KEY duplicate values
allow nahi karta (jaise do students ka same Roll No nahi ho sakta). NOT NULL matlab wo field khaali nahi
chhod sakte. FOREIGN KEY do tables ko connect karne ke liye use hota hai — jaise Student table ka
'ClassID' Class table ke primary key se link ho sakta hai. Ye rules data ko saaf-suthra (clean) aur
bharosemand (reliable) rakhte hain.
8. Inserting Data — INSERT INTO
Once a table is created, records (rows) are added to it using the INSERT INTO statement.
8.1 Syntax
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
8.2 Example
INSERT INTO Student (RollNo, Name, Age, Class, Marks)
VALUES (1, 'Aisha Khan', 16, '11-A', 88.50);
INSERT INTO Student (RollNo, Name, Age, Class, Marks)
VALUES (2, 'Rohan Sharma', 17, '11-B', 92.00);
• Text/string and date values must be written inside single quotes ' '
• Numeric values are written directly without quotes
💡 Concept Samjho (Hinglish):
INSERT INTO command se hum table mein ek naya record (row) daalte hain — jaise Excel sheet mein ek nayi
row bharna. Text values (jaise Name) hamesha single quotes '...' mein likhni hoti hai, lekin numbers (jaise
Age) bina quotes ke likhte hain. Order same hona chahiye jo columns mein specify kiya hai.
9. Retrieving Data — SELECT Statement
The SELECT statement is used to fetch/retrieve data from one or more tables. It is the most frequently used SQL
command.
9.1 Basic Syntax
SELECT column1, column2, ... FROM table_name;
-- To select all columns:
SELECT * FROM table_name;
9.2 Examples
-- Fetch all data from Student table
SELECT * FROM Student;
-- Fetch only Name and Marks
SELECT Name, Marks FROM Student;
9.3 Using WHERE Clause (Conditions)
The WHERE clause is used to filter records based on a specific condition.
SELECT * FROM Student WHERE Marks > 90;
SELECT * FROM Student WHERE Class = '11-A';
💡 Concept Samjho (Hinglish):
SELECT sabse zyada use hone wala command hai — isse hum table se data 'nikaal ke dekhte' hain. '*' ka
matlab hai 'saare columns dikhao'. WHERE clause se hum condition laga sakte hain — jaise sirf unhi students
ko dikhao jinke marks 90 se zyada hai. Yeh Excel ke 'filter' feature jaisa kaam karta hai.
10. Modifying and Removing Data
10.1 UPDATE Statement
The UPDATE statement is used to modify existing records in a table.
UPDATE table_name
SET column1 = value1, column2 = value2
WHERE condition;
-- Example:
UPDATE Student SET Marks = 95.00 WHERE RollNo = 1;
10.2 DELETE Statement
The DELETE statement removes one or more records from a table based on a condition.
DELETE FROM table_name WHERE condition;
-- Example:
DELETE FROM Student WHERE RollNo = 2;
📝 Important Warning
• Always use WHERE with UPDATE and DELETE — without WHERE, ALL rows in the table get updated or
deleted!
• DELETE removes only rows/data (table structure remains), while DROP TABLE removes the entire table
💡 Concept Samjho (Hinglish):
UPDATE se existing data ko change karte hain (jaise kisi student ke marks correct karna), aur DELETE se
kisi record ko table se hata dete hain. Sabse IMPORTANT baat: WHERE clause lagana kabhi mat bhoolna,
warna UPDATE/DELETE POORE table par apply ho jaayega — matlab saare records change/delete ho
jaayenge! Yeh sabse common mistake hai jo beginners karte hain.
11. Changing Table Structure — ALTER and DROP
11.1 ALTER TABLE — Add a Column
ALTER TABLE table_name ADD column_name datatype;
-- Example:
ALTER TABLE Student ADD Email VARCHAR(50);
11.2 ALTER TABLE — Modify a Column
ALTER TABLE table_name MODIFY column_name new_datatype;
-- Example:
ALTER TABLE Student MODIFY Age INT NOT NULL;
11.3 ALTER TABLE — Drop a Column
ALTER TABLE table_name DROP COLUMN column_name;
-- Example:
ALTER TABLE Student DROP COLUMN Email;
11.4 DROP TABLE
This permanently removes an entire table, including its structure and all data inside it.
DROP TABLE table_name;
💡 Concept Samjho (Hinglish):
ALTER TABLE se hum table ke structure ko baad mein change kar sakte hain — naya column add karna,
purane column ka data type badalna, ya column hatana. DROP TABLE aur DELETE mein farak yaad rakho:
DELETE sirf data hatata hai (table khaali reh jaata hai), lekin DROP TABLE poori table hi mita deta hai —
structure bhi chala jaata hai.
12. Quick Revision — Command Cheat Sheet
Task Command
Create a database CREATE DATABASE db_name;
Select a database to use USE db_name;
Create a table CREATE TABLE t (col type, ...);
View table structure DESC table_name;
Insert a record INSERT INTO t VALUES (...);
View all records SELECT * FROM t;
Filter records SELECT * FROM t WHERE cond;
Update records UPDATE t SET col=val WHERE cond;
Task Command
Delete records DELETE FROM t WHERE cond;
Add a column ALTER TABLE t ADD col type;
Delete entire table DROP TABLE t;
Delete entire database DROP DATABASE db_name;
💡 Concept Samjho (Hinglish):
Exam se pehle sirf yeh cheat sheet dekh lo — poore chapter ke saare commands ek jagah hain. Practice karne
ke liye MySQL Workbench ya XAMPP mein phpMyAdmin install kar sakte ho aur khud hi ye commands try
kar sakte ho — coding sikhne ka sabse best tareeka hai khud likh kar practice karna.
— End of Chapter Notes —