School DB Lab
school_learning_lab · live from MySQL

School Database Learning Lab

This is not a school management product. It is a hands-on laboratory built around a real, working school database, so you can see — not just read about — what a relational database actually does: how tables connect through keys, how constraints stop bad data, how JOINs pull related rows together, and what it looks like when something breaks.

یہ اسکول کے انتظام کا کوئی سافٹ ویئر نہیں ہے، بلکہ ایک پریکٹیکل لیبارٹری ہے جو ایک فعال اسکول ڈیٹا بیس (Database) کے گرد بنائی گئی ہے۔ اس لیب کا مقصد یہ ہے کہ آپ صرف نظریاتی باتیں پڑھنے کی بجائے عملی طور پر دیکھ سکیں کہ ایک ریلیشنل ڈیٹا بیس (Relational Database) دراصل کیا کام کرتا ہے: کس طرح ٹیبلز (Tables) پرائمری کی (Primary Key) اور فارن کی (Foreign Key) کے ذریعے آپس میں جڑتے ہیں، کنسٹرینٹس (Constraints) غلط ڈیٹا کو کیسے روکتے ہیں، جوائنز (JOINs) کے ذریعے مختلف ٹیبلز سے متعلقہ ریکارڈز کیسے اکٹھے ہوتے ہیں، اور جب کوئی غلطی ہوتی ہے تو ایرر (Error) کیسا نظر آتا ہے۔

21
Tables
295
Total rows (live)
17
Foreign Keys
24
Unique constraints

Start here

A sensible first path through the lab, in order:

1. See the shape of it

Open the Database Map for the full schema as a diagram, then Table Explorer for the detail behind each box.

2. Watch data connect

Add a record in the Data Entry Lab and watch its new Primary Key get generated and linked live.

3. Pull it back out

Work through the 12 worked examples in the Query & Retrieval Lab, from a single SELECT up to multi-table JOINs and aggregation.

4. Break it on purpose

Try a duplicate value or an invalid link in the Keys & Constraints Lab, then confirm the database is healthy in the Integrity Checker.

What you'll be able to explain by the end

STRUCTURE

Tables, rows/columns, data types, Primary Keys, Foreign Keys, UNIQUE constraints, NOT NULL, DEFAULT values, CHECK constraints.

RELATIONSHIPS

One-to-One, One-to-Many, Many-to-Many, junction tables, and how a Foreign Key value is literally what "connects" two rows.

OPERATIONS

INSERT, SELECT, UPDATE, DELETE, JOIN, filtering, sorting, aggregation, GROUP BY, transactions.

INTEGRITY

Referential integrity, duplicate prevention, orphan records, and why we never turn constraints off to make an error go away.

PERFORMANCE

Indexes, composite indexes, reading an EXPLAIN plan, and the real trade-offs an index makes.

TROUBLESHOOTING

Diagnosing a failed INSERT, an unexpected JOIN result, or a slow query — and fixing the cause, not the symptom.

The school, in thirteen tables

TablePurposeRows right now
attendance Daily attendance, one row per student per class per date. 70
classes A class/section for one academic year, e.g. "Grade 5 - A - 2025-2026". 4
class_subject_teachers Assignment table answering: which teacher teaches which subject to which class. 24
exams One row per exam sitting for a given class. 2
exam_results A student's marks for one subject in one exam. 30
fee_invoices One invoice per student per billing month. 40
fee_payments Payments received against an invoice — one invoice may have several partial payments. 20
lab_admins 1
lab_invitations 0
lab_login_attempts 10
lab_record_ownership 0
lab_settings 1
lab_students 0
lab_task_progress 0
lab_teachers 2
parents Parents/guardians. Never linked to students directly — always through student_parents. 12
students The root entity. Most other tables ultimately point back to a student. 20
student_enrollments Connects students to the classes they are enrolled in (One-to-Many on both sides). 18
student_parents Junction table resolving the Many-to-Many relationship between students and parents. 30
subjects Catalogue of subjects taught across the school. 6
teachers School teaching staff. 5
Explain this page
What am I looking at?
Live counts pulled straight from information_schema and COUNT(*) on every table — not hard-coded numbers. If you add or delete data anywhere in the lab, this page reflects it immediately.
Why does this matter?
It's proof that the whole app reads the database, rather than a separate copy of "documentation" that could quietly go stale.
یہاں کیا نظر آ رہا ہے؟
یہ تعداد براہِ راست information_schema اور COUNT(*) کے ذریعے ہر ٹیبل سے لائیو پڑھی جا رہی ہے — یہ ہارڈ کوڈڈ (Hard-coded) نمبر نہیں ہیں۔ اگر آپ لیب میں کہیں بھی ڈیٹا شامل یا حذف کریں، تو یہ صفحہ فوری طور پر اسے ظاہر کرے گا۔
یہ کیوں اہم ہے؟
یہ اس بات کا ثبوت ہے کہ پوری ایپلیکیشن ڈیٹا بیس سے براہِ راست ڈیٹا پڑھتی ہے — کسی الگ "دستاویز" کی نقل سے نہیں جو پرانی ہو سکتی ہے۔