SQL DATABASE
Exam Power Notes • Quick Revision Guide
Description: Concise SQL and database revision notes covering DBMS concepts, SQL commands, keys, queries,
JOINs, aggregate functions, normalization, exam questions and MCQs.
Keywords: SQL Notes, Database Notes, SQL Exam, DBMS, SQL Queries, SELECT, JOIN, Primary Key, Foreign Key,
Normalization, Exam Preparation, Study Notes, Quick Revision
1. Database & DBMS Basics
• A database is an organized collection of related data.
• DBMS is software used to create, store, retrieve, update and manage data.
• A relational database stores data mainly in tables containing rows and columns.
2. Important Terms
• Table: collection of related records.
• Row/Record: one complete data entry.
• Column/Field: an attribute describing data.
• Primary Key: uniquely identifies a row.
• Foreign Key: references a key in another table.
3. SQL Command Categories
• DDL: CREATE, ALTER, DROP — database structure.
• DML: INSERT, UPDATE, DELETE — data modification.
• DQL: SELECT — data retrieval.
• DCL: GRANT, REVOKE — permissions.
• TCL: COMMIT, ROLLBACK — transactions.
4. Essential SQL Syntax
SELECT name, age FROM students;
SELECT * FROM students WHERE age > 18;
INSERT INTO students (name, age) VALUES ('Ali', 20);
UPDATE students SET age = 21 WHERE name = 'Ali';
DELETE FROM students WHERE name = 'Ali';
5. Filtering, Sorting & Grouping
WHERE filters rows. ORDER BY sorts results. GROUP BY groups rows. HAVING filters grouped results.
SELECT * FROM students ORDER BY age DESC;
SELECT department, COUNT(*) FROM students GROUP BY department;
SELECT department, COUNT(*) FROM students GROUP BY department HAVING COUNT(*) > 5;
6. Aggregate Functions
Common functions: COUNT(), SUM(), AVG(), MIN(), and MAX().
Exam Power Notes • Quick Revision Guide
Description: Concise SQL and database revision notes covering DBMS concepts, SQL commands, keys, queries,
JOINs, aggregate functions, normalization, exam questions and MCQs.
Keywords: SQL Notes, Database Notes, SQL Exam, DBMS, SQL Queries, SELECT, JOIN, Primary Key, Foreign Key,
Normalization, Exam Preparation, Study Notes, Quick Revision
1. Database & DBMS Basics
• A database is an organized collection of related data.
• DBMS is software used to create, store, retrieve, update and manage data.
• A relational database stores data mainly in tables containing rows and columns.
2. Important Terms
• Table: collection of related records.
• Row/Record: one complete data entry.
• Column/Field: an attribute describing data.
• Primary Key: uniquely identifies a row.
• Foreign Key: references a key in another table.
3. SQL Command Categories
• DDL: CREATE, ALTER, DROP — database structure.
• DML: INSERT, UPDATE, DELETE — data modification.
• DQL: SELECT — data retrieval.
• DCL: GRANT, REVOKE — permissions.
• TCL: COMMIT, ROLLBACK — transactions.
4. Essential SQL Syntax
SELECT name, age FROM students;
SELECT * FROM students WHERE age > 18;
INSERT INTO students (name, age) VALUES ('Ali', 20);
UPDATE students SET age = 21 WHERE name = 'Ali';
DELETE FROM students WHERE name = 'Ali';
5. Filtering, Sorting & Grouping
WHERE filters rows. ORDER BY sorts results. GROUP BY groups rows. HAVING filters grouped results.
SELECT * FROM students ORDER BY age DESC;
SELECT department, COUNT(*) FROM students GROUP BY department;
SELECT department, COUNT(*) FROM students GROUP BY department HAVING COUNT(*) > 5;
6. Aggregate Functions
Common functions: COUNT(), SUM(), AVG(), MIN(), and MAX().