Normalisation · التعديل
Why normalise?
Imagine storing every club booking in one table, with the coach repeated on every row: each booking of the Chess club would carry "Mr Ng" again and again.
That repetition causes problems. If Mr Ng leaves, you must update many rows; miss one and the data becomes inconsistent. Normalisation organises tables to remove this kind of redundancy.
لماذا التطبيع؟
تخزن كل حجز نادٍ في جدول واحد، مع تكرار المدرب في كل صف: كل حجز للنادي الشطرنج سيحمل "Mr Ng" مراراً وتكراراً.
هذا التكرار يسبب مشاكل. إذا غادر Mr Ng، يجب عليك تحديث العديد من الصفوف؛ إذا فاتتك واحدة، تصبح البيانات غير متسقة. التطبيع ينظم الجداول لإزالة هذا النوع من التكرار.
The normal forms
You normalise in steps:
- 1NF — every cell holds a single value (no lists or repeating groups), and the table has a primary key.
- 2NF — already 1NF, and no non-key column depends on only part of a composite key.
- 3NF — already 2NF, and no non-key column depends on another non-key column (no transitive dependency).
In the one-table version, coach depends on the club, not on the booking — a transitive dependency, so it is not in 3NF.
الأشكال المعيارية
تقوم بالتطبيع في خطوات:
- 1NF — كل خلية تحمل قيمة واحدة (بدون قوائم أو مجموعات مكررة)، والجدول له مفتاح أساسي.
- 2NF — بالفعل 1NF، ولا يعتمد عمود غير مفتاحي على جزء فقط من مفتاح مركب.
- 3NF — بالفعل 2NF، ولا يعتمد عمود غير مفتاحي على عمود غير مفتاحي آخر (لا اعتماد انتقالي).
في نسخة جدول واحد، coach يعتمد على club، وليس على الحجز — اعتماد انتقالي، لذا فهو ليس في 3NF.
The normalised design
We split the data into two tables (the ones loaded here):
club(club_id, name, coach)— each club and its coach, stored once.booking(booking_id, student, club_id)— each booking, linked by the foreign keyclub_id.
Now a coach is stored once. A JOIN puts the information back together whenever you need it — write that join below.
التصميم المطبّق
قمنا بتقسيم البيانات إلى جدولين (التي تم تحميلها هنا):
club(club_id, name, coach)— كل نادٍ ومدربه، مخزناً مرة واحدة.booking(booking_id, student, club_id)— كل حجز، مرتبط بالمفتاح الأجنبيclub_id.
الآن يتم تخزين المدرب مرة واحدة. يقوم JOIN بإعادة تجميع المعلومات كلما احتجت إليها — اكتب جملة الوصل أدناه.
Common mistakes
- Split repeating groups into their own table instead of many similar columns.
- Each table should describe one kind of thing.
أخطاء شائعة
- تقسيم المجموعات المكررة إلى جدول خاص بها بدلاً من أعمدة متعددة مشابهة.
- يجب أن يصف كل جدول نوعًا واحدًا من الأشياء.
Reassemble the data: list each booking's student next to their club's coach, by joining booking to club on club_id, ordered by booking.booking_id. · أعد تجميع البيانات: اذكر student كل حجز بجانب coach ناديهم، عن طريق ربط booking بـ club عبر club_id، مرتباً حسب booking.booking_id.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
The split tables still answer questions together. Count how many bookings each club has: join booking to club, show club.name and COUNT(*) AS bookings, group by the club, and order by club.name. · لا تزال الجداول المجزأة تجيب عن الأسئلة معاً. احسب عدد الحجوزات لكل نادي: اربط booking بـ club، أظهّر club.name و COUNT(*) AS bookings، جمّع حسب النادي، ورتّب حسب club.name.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.