**1. Why Databases? — From Paper Registers to NADRA**
Imagine keeping records for an entire country on paper — that's why modern organisations use computerised databases. In Pakistan, NADRA maintains a database linking a citizen's CNIC number to identity information. Databases make large-scale record keeping possible.
A database is an organised collection of structured data stored electronically. A Database Management System (DBMS) is the software that manages the database (e.g., MySQL, PostgreSQL, SQLite).
Why databases over spreadsheets?
Handle millions of records efficiently
Multiple users can access simultaneously
Built-in security and access control
Reduce data redundancy (avoid duplicate data)
Maintain data integrity and consistency
**2. Database Structure — Tables, Records, and Fields**
A relational database stores data in tables (also called relations).
UPDATE Students SET City = 'Faisalabad' WHERE StudentID = 1003;
```
DELETE — remove records:
```sql
DELETE FROM Students WHERE StudentID = 1002;
```
Important SQL clauses:
WHERE: filter rows by condition
ORDER BY: sort results (ASC for ascending, DESC for descending)
AND / OR: combine conditions
LIKE: pattern matching (`WHERE Name LIKE 'A%'` finds names starting with A)
Example: "Find all students in Karachi studying Computer Science, sorted by name":
```sql
SELECT * FROM Students
WHERE City = 'Karachi' AND Subject = 'Computer Science'
ORDER BY Name ASC;
```
**4. Database Design and Validation**
Validation checks that data entered is reasonable:
Range check: marks must be between 0 and 100
Length check: CNIC must be exactly 13 digits
Type check: age must be a number, not text
Presence check: name field cannot be empty
Format check: email must contain @ symbol
Verification checks that data entered matches the source:
Double entry: type data twice and compare
Visual check: human reads and confirms
Normalisation reduces redundancy by splitting data into related tables linked by keys. Instead of repeating "Karachi" 1000 times in one table, create a Cities table and link by CityID.
**5. Exam Strategy**
SQL syntax must be exact — capitalise keywords (SELECT, FROM, WHERE) for clarity.
String values in SQL use single quotes: `WHERE City = 'Karachi'` not double quotes.
Primary key question: choose the field that is UNIQUE for every record.
When asked to write a query, read the question carefully — does it say "all fields" (use *) or "specific fields" (list them)?
Validation vs verification: validation = is the data reasonable? Verification = is it what was intended?
ORDER BY defaults to ASC — only specify DESC when needed.
Key Points to Remember
1Database stores structured data in tables; DBMS manages it (MySQL, SQLite)
2Primary key uniquely identifies each record; foreign key links tables
4WHERE filters, ORDER BY sorts, AND/OR combine conditions
5Validation checks data is reasonable; verification checks it matches the source
Pakistan Example
NADRA's CNIC Database — Primary Keys in Real Life
NADRA's database links a 13-digit CNIC number (a primary key) to identity data across related tables. The key exam idea: a primary key uniquely identifies one record, so a search can quickly return the exact row you need.
Quick Revision Infographic
Computer Science — Quick Revision
Databases and SQL
Key Concepts
1Database stores structured data in tables; DBMS manages it (MySQL, SQLite)
2Primary key uniquely identifies each record; foreign key links tables
4WHERE filters, ORDER BY sorts, AND/OR combine conditions
5Validation checks data is reasonable; verification checks it matches the source
Formulas to Know
AND/OR combine conditions
Pakistan Example
NADRA's CNIC Database — Primary Keys in Real Life
NADRA's database links a 13-digit CNIC number (a primary key) to identity data across related tables. The key exam idea: a primary key uniquely identifies one record, so a search can quickly return the exact row you need.
SeekhoAsaan.com — Free RevisionDatabases and SQL Infographic
Stage 3: End-of-Topic Summary Video
End the topic with a concise recap of key takeaways, formulas, and revision reminders.
Summary
30-60 sec
Provide a concise revision recap with key formulas/definitions and next steps.
Placed near the end of the topic journey.
Dry-run assets generated
Written lesson and quiz remain available while this stage video is being prepared.