Chapterبەش 4 · Lectureوانە 4.2
Normalizationنۆرماڵکردن
An added lesson: how to split a badly designed table step by step so that every fact is stored once. Functional dependencies; the insertion, deletion and modification anomalies; first, second and third normal form, and BCNF in short — all worked on one university registration sheet.
وانەیەکی زیادکراو: چۆن خشتەیەکی خراپ دیزاینکراو هەنگاو بە هەنگاو لەت دەکرێت بۆ ئەوەی هەر ڕاستییەک یەک جار هەڵبگیرێت. ؛ ، و ؛ ، و و BCNF بە کورتی — هەمووی لەسەر یەک پەڕەی تۆمارکردنی زانکۆ.
What you will learnچی فێر دەبیت
- Explain why repeated data causes insertion, deletion and modification anomalies.
- Read and write functional dependencies, and find the determinant of each.
- Bring a table to first, second and third normal form, step by step.
- Tell partial dependencies from transitive ones, and check a table against BCNF.
- Split tables without losing information, keeping the right keys and foreign keys.
- ڕوونی بکەیتەوە بۆچی دووبارە دەبێتە هۆی ، و .
- بخوێنیتەوە و بنووسیت و هەریەکەیان بدۆزیتەوە.
- خشتەیەک هەنگاو بە هەنگاو بگەیەنیتە ، و .
- لە جیا بکەیتەوە و خشتەیەک بەرامبەر BCNF بپشکنیت.
- خشتەکان بەبێ لەدەستدانی لەت بکەیت و و ڕاست بهێڵیتەوە.
Why normalize?بۆچی نۆرماڵکردن؟
Splitting data into well-designed tables so that each fact is stored in exactly one place. It removes and the that it causes.
دابەشکردنی دراوەیە بۆ چەند خشتەیەکی باش دیزاینکراو، بۆ ئەوەی هەر ڕاستییەک تەنها لە یەک شوێندا خەزن بکرێت. لادەبات، لەگەڵ ئەو کە لێیەوە دروست دەبن.
In Database keys you saw a table that mixed students and departments: one change had to be made in many rows, and deleting one row destroyed a different fact. Normalization is the step-by-step method that fixes this. It splits a table into smaller tables so that every fact is stored once, and keys join the pieces again whenever you need them.
لە کلیلەکانی بنکەدراوە خشتەیەکت بینی کە قوتابی و بەشەکانی تێکەڵ کردبوو: یەک گۆڕانکاری دەبوو لە چەندین بکرێت و سڕینەوەی یەک ڕاستییەکی تری لەناو دەبرد. ئەو ڕێگا هەنگاو بە هەنگاوەیە کە ئەمە چاک دەکاتەوە. خشتەیەک لەت دەکات بۆ چەند خشتەیەکی بچووکتر، بۆ ئەوەی هەر ڕاستییەک تەنها یەک جار هەڵبگیرێت و هەر کاتێک پێویستت بوو پارچەکان پێکەوە دەبەستنەوە.
Normalization does not remove every repetition. The columns that link the tables – the foreign keys – still repeat: CS appears in the row of every computer-science student. That small, planned repetition is called controlled redundancy: everything else is stored once.
هەموو دووبارەبوونەوەیەک لانابات. ئەو دەبەستنەوە – – هێشتا دووبارە دەبنەوە: CS لە هەموو قوتابییەکی زانستی کۆمپیوتەردا دەردەکەوێت. ئەو دووبارەبوونەوە بچووک و پلان بۆ دانراوە پێی دەوترێت دووبارەبوونەوەی کۆنترۆڵکراو (controlled redundancy): هەموو شتێکی تر یەک جار هەڵدەگیرێت.
A shopkeeper in the Sulaimani bazaar writes every sale in a notebook: the date, the item, and next to every line the supplier's name and phone number. When a supplier changes his number, the shopkeeper must correct hundreds of lines, and he will miss some. A better notebook has one page of suppliers, each written once, and next to each sale only a short supplier code. That is normalization.
دوکاندارێک لە بازاڕی سلێمانی هەموو فرۆشتنێک لە دەفتەرێکدا دەنووسێت: ڕێکەوت، کاڵاکە و لە تەنیشت هەموو دێڕێکەوە ناو و ژمارەی مۆبایلی دابینکەرەکە. کاتێک دابینکەرێک ژمارەکەی دەگۆڕێت، دوکاندار دەبێت سەدان دێڕ چاک بکاتەوە و هەندێکیان لە بیر دەچێت. دەفتەرێکی باشتر یەک لاپەڕەی دابینکەرانی هەیە، هەریەکەیان یەک جار نووسراوە و لە تەنیشت هەر فرۆشتنێکەوە تەنها کۆدێکی کورتی دابینکەر. ئەمە .
Where the analogy stops workingسنووری ئەم نموونەیە
Paper does not join pages for you, but a database does: with keys and joins it puts the pieces back together in a moment. Still, every join costs a little time, so some very large reporting systems keep a little repetition on purpose (see the end of the lesson).
کاغەز لاپەڕەکان بۆت پێکەوە نابەستێتەوە، بەڵام ئەم کارە دەکات: بە و لە ساتێکدا پارچەکان پێکەوە دەنێتەوە. لەگەڵ ئەوەشدا هەر کەمێک کات دەبات، بۆیە هەندێک سیستەمی ڕاپۆرتی زۆر گەورە بە ئەنقەست کەمێک دووبارەبوونەوە دەهێڵنەوە (لە کۆتایی وانەکەدا).
The starting point: a registration sheetخاڵی دەستپێک: پەڕەی تۆمارکردن
The office of a college in Sulaimani keeps the registrations of one semester in a single spreadsheet. There is one row for each student, and all of a student's courses are typed into one cell:
نووسینگەی کۆلێژێک لە سلێمانی تۆمارکردنەکانی یەک وەرز لە یەک هەڵدەگرێت. بۆ هەر قوتابییەک یەک هەیە و هەموو وانەکانی قوتابییەک لە یەک خانەدا نووسراون:
student_no | student_name | dept_code | dept_name | courses |
|---|---|---|---|---|
| 2024-0137 | Aram Kamal | CS | Computer Science | DB101 Database Fundamentals (3) B; WP101 Web Programming (3) A |
| 2024-0152 | Shilan Omar | IT | Information Technology | DB101 Database Fundamentals (3) C |
| 2024-0188 | Karwan Aziz | CS | Computer Science | DB201 Database Administration (3) A; WP101 Web Programming (3) B |
It looks tidy, but try to use it. 'Which students take WP101?' needs a text search inside every cell. No key can point to one course inside a cell. And 'Database Fundamentals (3)' is typed again for every student who takes it. We will normalize this sheet in three steps: 1NF, 2NF and 3NF.
ڕێکوپێک دەردەکەوێت، بەڵام هەوڵ بدە بەکاری بهێنیت. «کام قوتابییانە WP101 دەخوێنن؟» پێویستی بە گەڕانی دەق لەناو هەموو خانەیەکدا هەیە. هیچ ناتوانێت ئاماژە بۆ یەک وانە لەناو خانەیەکدا بکات. هەروەها «Database Fundamentals (3)» بۆ هەر قوتابییەک کە دەیخوێنێت دووبارە دەنووسرێتەوە. ئەم پەڕەیە بە سێ هەنگاو نۆرماڵ دەکەین: 1NF، 2NF و 3NF.
Step 1: first normal form (1NF)هەنگاوی ١: شێوەی نۆرماڵی یەکەم (1NF)
A table is in first normal form (1NF) when every cell holds one single value (), with no lists and no repeating groups of columns.
خشتەیەک لە (1NF) دەبێت کاتێک هەموو تەنها یەک نرخ هەڵدەگرێت ()، بەبێ لیست و بەبێ کۆمەڵە ستوونی دووبارەبووەوە.
The rule of 1NF: every cell holds one atomic value. No lists in a cell, and no repeating groups of columns such as course1, course2, course3. It is the third of the three properties of a relation.
ڕێسای 1NF: هەموو خانەیەک یەک هەڵدەگرێت. نە لیست لە خانەیەکدا، نە کۆمەڵە دووبارەبووەوە وەک course1، course2، course3. ئەمە سێیەمیانە لە سێ تایبەتمەندییەکەی relation.
Give every course its own row. Copy the student's data into each of their rows.
هەموو وانەیەک تایبەت بە خۆی بدەرێ. قوتابییەکە بۆ هەریەکە لە کۆپی بکە.
Split the course text into separate columns:
course_code,course_title,credits,grade.دەقی وانەکە بۆ چەند جیا لەت بکە:
course_code،course_title،credits،grade.Choose the key. A student has many rows now, so
student_noalone repeats.(student_no, course_code)is unique: it becomes the primary key.کلیلەکە هەڵبژێرە. ئێستا قوتابییەک چەند هەیە، بۆیە
student_noبە تەنها دووبارە دەبێتەوە.(student_no, course_code)یەکتایە: دەبێتە .
student_no | course_code | student_name | dept_code | dept_name | course_title | credits | grade |
|---|---|---|---|---|---|---|---|
| 2024-0137 | DB101 | Aram Kamal | CS | Computer Science | Database Fundamentals | 3 | B |
| 2024-0137 | WP101 | Aram Kamal | CS | Computer Science | Web Programming | 3 | A |
| 2024-0152 | DB101 | Shilan Omar | IT | Information Technology | Database Fundamentals | 3 | C |
| 2024-0188 | DB201 | Karwan Aziz | CS | Computer Science | Database Administration | 3 | A |
| 2024-0188 | WP101 | Karwan Aziz | CS | Computer Science | Web Programming | 3 | B |
1NF is not enough: the anomalies are still there1NF بەس نییە: ناڕێکییەکان هێشتا ماون
The 1NF table has one value per cell, but look at the repetition: 'Computer Science' four times, each course title twice, each student's name in every one of their rows. All three update anomalies of the course appear:
خشتە 1NFـەکە یەک نرخی لە هەر خانەیەکدا هەیە، بەڵام سەیری دووبارەبوونەوەکە بکە: «Computer Science» چوار جار، ناونیشانی هەر وانەیەک دوو جار و ناوی هەر قوتابییەک لە هەموو . هەر سێ جۆرەکەی کە کۆرسەکە باسی کردوون دەردەکەون:
- Insertion anomaly: the college plans a new course, AI301 Artificial Intelligence (4 credits). It cannot be stored until a student enrols, because
student_nois part of the key and cannot be NULL. - Deletion anomaly: Shilan drops DB101, her only course. Deleting that row also deletes Shilan herself and the only record that IT means Information Technology.
- Modification anomaly: WP101 is renamed 'Web Programming with PHP'. Two rows must change (in a real college, hundreds). Miss one, and the database gives two titles for one course.
- : کۆلێژەکە وانەیەکی نوێ پلان دەکات، AI301 Artificial Intelligence (4 یەکە). تا قوتابییەک تۆمار نەکرێت ناتوانرێت هەڵبگیرێت، چونکە
student_noبەشێکە لە کلیلەکە و ناتوانێت NULL بێت. - : شیلان DB101 بەجێ دەهێڵێت، کە تاکە وانەکەیەتی. سڕینەوەی ئەو خودی شیلانیش دەسڕێتەوە، لەگەڵ تاکە تۆمارێک کە دەڵێت IT واتە Information Technology.
- : ناوی WP101 دەکرێتە «Web Programming with PHP». دوو دەبێت بگۆڕدرێن (لە کۆلێژێکی ڕاستەقینەدا سەدان). ئەگەر یەکێکیان لە بیر بچێت، دوو ناونیشان بۆ یەک وانە دەدات.
To remove these anomalies we need a precise way to say which column belongs with which. That tool is the functional dependency.
بۆ لابردنی ئەم ناڕێکییانە پێویستمان بە ڕێگایەکی ورد هەیە بۆ ئەوەی بڵێین کام لەگەڵ کامیاندا دەڕوات. ئەو ئامرازە .
Functional dependencyوابەستەیی فەنکشنی
A rule X → Y between columns of a table: whenever two rows have the same value in X, they must also have the same value in Y. We say 'X determines Y'.
ڕێسایەکی X → Yـیە لە نێوان ستوونەکانی خشتەیەکدا: هەر کاتێک دوو ڕیز لە Xـدا هەمان نرخیان هەبێت، دەبێت لە Yـیشدا هەمان نرخیان هەبێت. دەڵێین «X، Y دیاری دەکات».
We write a functional dependency as X → Y and read it 'X determines Y'. It holds when any two rows that have the same value in X also have the same value in Y. X is called the determinant. In our table, course_code → course_title, credits: every row with DB101 says 'Database Fundamentals' and 3 credits.
بەم شێوەیە دەنووسین: X → Y و دەیخوێنینەوە «X، Y دیاری دەکات». کاتێک ڕاستە کە هەر دوو لە Xدا هەمان نرخیان هەبێت، لە Yیشدا هەمان نرخیان هەبێت. X پێی دەوترێت . لە خشتەکەماندا course_code → course_title, credits: هەموو کە DB101ی تێدایە دەڵێت «Database Fundamentals» و 3 یەکە.
- Keys in this language: a set K is a super key when K → every column of the table; it is a candidate key when no smaller part of K does that. Here
(student_no, course_code)determines everything. - Trivial dependency: X → Y where Y is already part of X, such as
(student_no, course_code) → course_code. It is always true and tells us nothing. - From the E-R diagram: every N:1 relationship is a dependency. Each lecturer works in one department, so
lecturer_no → dept_code. A 1:1 relationship gives one in each direction:dean_no → college_codeandcollege_code → dean_no.
- بەم زمانە: کۆمەڵەی K کاتێک K ← هەموو خشتەکە؛ کاتێک هیچ بەشێکی بچووکتری K ئەمە نەکات. لێرەدا
(student_no, course_code)هەموو شتێک دیاری دەکات. - وابەستەیی بێبایەخ: X → Y کە Y پێشتر بەشێکە لە X، وەک
(student_no, course_code) → course_code. هەمیشە ڕاستە و هیچمان پێ نالێت. - لە : هەموو
N:1وابەستەییەکە. هەر مامۆستایەک لە یەک بەشدا کار دەکات، بۆیەlecturer_no → dept_code.1:1لە هەر ئاراستەیەک یەکێک دەدات:dean_no → college_codeوcollege_code → dean_no.
Functional dependencyوابەستەیی فەنکشنی
The dependencies of our tableوابەستەییەکانی خشتەکەمان
The college's rules give four functional dependencies for registration:
ڕێساکانی کۆلێژەکە چوار بۆ registration دەدەن:
student_no → student_name, dept_code— a student has one name and one department.dept_code → dept_name— a department code has one name.course_code → course_title, credits— a course has one title and one number of credits.student_no, course_code → grade— a grade belongs to one student in one course.
student_no → student_name, dept_code— قوتابییەک یەک ناو و یەک بەشی هەیە.dept_code → dept_name— کۆدی بەشێک یەک ناوی هەیە.course_code → course_title, credits— وانەیەک یەک ناونیشان و یەک ژمارەی یەکەی هەیە.student_no, course_code → grade— نمرەیەک هی یەک قوتابییە لە یەک وانەدا.
The only candidate key is (student_no, course_code), so student_no and course_code are the prime attributes; all the others are non-prime. Dependency 4 is fine: grade needs the whole key. Dependencies 1 and 3 are partial: a non-prime column needs only part of the key. Dependency 2 makes dept_name depend on the key only through dept_code: a transitive dependency. 2NF removes the first kind, 3NF the second.
تاکە (student_no, course_code)ـە، بۆیە student_no و course_code ؛ هەموو ئەوانی تر . وابەستەیی ٤ باشە: grade پێویستی بە هەموو کلیلەکە هەیە. وابەستەییەکانی ١ و ٣ بەشەکین: ناسەرەتایی تەنها پێویستی بە بەشێک لە کلیلەکە هەیە. وابەستەیی ٢ وا دەکات dept_name تەنها لە ڕێگەی dept_codeـەوە پشت بە کلیلەکە ببەستێت: . 2NF جۆری یەکەم لادەبات و 3NF جۆری دووەم.
Step 2: second normal form (2NF)هەنگاوی ٢: شێوەی نۆرماڵی دووەم (2NF)
A table is in second normal form (2NF) when it is in 1NF and every depends on the whole of every , not on part of one (no ).
خشتەیەک لە (2NF) دەبێت کاتێک لە 1NFـدا بێت و هەموو پشت بە هەموو ببەستێت، نەک بە بەشێکی (هیچ نەبێت).
The rule of 2NF: the table is in 1NF, and no non-prime attribute depends on only part of a candidate key. Every non-key column must depend on the whole key. A table whose candidate keys all have one column cannot break this rule; only tables with a composite key can.
ڕێسای 2NF: خشتەکە لە 1NFدایە و هیچ تەنها پشت بە بەشێک لە نابەستێت. هەموو ناکلیلی دەبێت پشت بە هەموو کلیلەکە ببەستێت. خشتەیەک کە هەموو یەک بن ناتوانێت ئەم ڕێسایە بشکێنێت؛ تەنها خشتەکانی خاوەن دەتوانن.
Find the partial dependencies:
student_no → student_name, dept_code(and with itdept_name), andcourse_code → course_title, credits.بدۆزەوە:
student_no → student_name, dept_code(و لەگەڵیداdept_name) وcourse_code → course_title, credits.Move each group into a new table whose key is that part of the old key:
student(student_no, student_name, dept_code, dept_name)andcourse(course_code, course_title, credits).هەر کۆمەڵەیەک بگوازەوە بۆ خشتەیەکی نوێ کە کلیلەکەی ئەو بەشەی کلیلە کۆنەکە بێت:
student(student_no, student_name, dept_code, dept_name)وcourse(course_code, course_title, credits).Keep what depends on the whole key in the old table:
enrolment(student_no, course_code, grade). Its two key columns are now also foreign keys tostudentandcourse.ئەوەی پشت بە هەموو کلیلەکە دەبەستێت لە خشتە کۆنەکەدا بهێڵەوە:
enrolment(student_no, course_code, grade). دوو کلیلییەکەی ئێستا هەروەها بۆstudentوcourse.
Step 2: second normal form (2NF)هەنگاوی ٢: شێوەی نۆرماڵی دووەم (2NF)
The three tables after 2NFسێ خشتەکە دوای 2NF
student_no | student_name | dept_code | dept_name |
|---|---|---|---|
| 2024-0137 | Aram Kamal | CS | Computer Science |
| 2024-0152 | Shilan Omar | IT | Information Technology |
| 2024-0188 | Karwan Aziz | CS | Computer Science |
course_code | course_title | credits |
|---|---|---|
| DB101 | Database Fundamentals | 3 |
| DB201 | Database Administration | 3 |
| WP101 | Web Programming | 3 |
student_no | course_code | grade |
|---|---|---|
| 2024-0137 | DB101 | B |
| 2024-0137 | WP101 | A |
| 2024-0152 | DB101 | C |
| 2024-0188 | DB201 | A |
| 2024-0188 | WP101 | B |
Each course title is now stored once, and the new course AI301 can be added to course before anyone enrols. But 'Computer Science' is still written twice in student.
ئێستا ناونیشانی هەر وانەیەک تەنها یەک جار هەڵگیراوە و وانە نوێیەکەی AI301 دەتوانرێت پێش تۆمارکردنی هەر کەسێک بخرێتە ناو course. بەڵام «Computer Science» هێشتا دوو جار لە studentدا نووسراوە.
Step 3: third normal form (3NF)هەنگاوی ٣: شێوەی نۆرماڵی سێیەم (3NF)
A table is in third normal form (3NF) when it is in 2NF and no depends on a key through another non-key column (no ).
خشتەیەک لە (3NF) دەبێت کاتێک لە 2NFـدا بێت و هیچ لە ڕێگەی ستوونێکی تری ناکلیلییەوە پشت بە کلیل نەبەستێت (هیچ نەبێت).
The rule of 3NF: the table is in 2NF, and no non-prime attribute depends on a key through another non-key column (no transitive dependency). In student, student_no → dept_code → dept_name: the department's name is a fact about the department, not about the student.
ڕێسای 3NF: خشتەکە لە 2NFدایە و هیچ لە ڕێگەی تری ناکلیلییەوە پشت بە کلیل نابەستێت (هیچ نییە). لە studentدا، student_no → dept_code → dept_name: ناوی بەش ڕاستییەکە دەربارەی بەشەکە، نەک دەربارەی قوتابییەکە.
Move the transitive part into a new table keyed by its determinant:
department(dept_code, dept_name).بەشە ناڕاستەوخۆکە بگوازەوە بۆ خشتەیەکی نوێ کە کلیلەکەی بێت:
department(dept_code, dept_name).Keep the determinant in the old table as a foreign key:
student(student_no, student_name, dept_code).لە خشتە کۆنەکەدا وەک بهێڵەوە:
student(student_no, student_name, dept_code).
dept_code | dept_name |
|---|---|
| CS | Computer Science |
| IT | Information Technology |
The result is four tables — department, student, course and enrolment — exactly the database of the Database keys lesson. The three anomalies are gone: AI301 is added to course alone; deleting Shilan's enrolment keeps Shilan and the IT department; renaming WP101 changes one row.
ئەنجامەکە چوار خشتەیە — department، student، course و enrolment — ڕێک وانەی کلیلەکانی بنکەدراوە. هەر سێ ناڕێکییەکە نەمان: AI301 بە تەنها دەخرێتە ناو course؛ سڕینەوەی تۆمارکردنی شیلان، شیلان و بەشی IT دەهێڵێتەوە؛ گۆڕینی ناوی WP101 یەک دەگۆڕێت.
Step 3: third normal form (3NF)هەنگاوی ٣: شێوەی نۆرماڵی سێیەم (3NF)
The whole road at a glanceهەموو ڕێگاکە بە یەک سەیرکردن
Each normal form includes the ones before it: a table in 3NF is also in 2NF and in 1NF. In daily work, 'normalized' usually means 'in 3NF' (or BCNF, next screen).
هەر ئەوانەی پێش خۆی لەخۆ دەگرێت: خشتەیەک کە لە 3NFدا بێت لە 2NF و 1NFـیشدایە. لە کاری ڕۆژانەدا «نۆرماڵکراو» زۆرجار واتە «لە 3NFدا» (یان BCNF، پەڕەی داهاتوو).
In Kurdish, a flat table is split step by step into first, second and third normal form so that the database has no repeated data.
بە کوردی، یەکپارچە پلەبەپلە پارچە دەکرێت و دەگاتە ، و ، تا هیچ دووبارەی تێدا نەبێت.
Kurdish walk-through of 1NF, 2NF and 3NF on English slides. The rules on the slides agree with this lesson.
ڕوونکردنەوەیەکی کوردیی ، و لەسەر ئینگلیزی. ڕێساکانی سەر لەگەڵ ئەم وانەیە یەک دەگرنەوە.
Boyce–Codd normal form (BCNF), brieflyشێوەی نۆرماڵی بۆیس-کۆد (BCNF)، بە کورتی
A stricter form of : for every X → Y that is not trivial, X must be a .
شێوەیەکی توندتری : بۆ هەموو X → Y کە بێبایەخ نەبێت، دەبێت X بێت.
BCNF has one simple rule: every determinant must be a super key — for every dependency X → Y that is not trivial, X must identify the rows. 3NF allows one exception: when Y is a prime attribute, X need not be a super key. BCNF removes that exception. Our four university tables are already in BCNF: in each of them, the only determinant is the table's own key.
BCNF یەک ڕێسای سادەی هەیە: هەموو دەبێت بێت — بۆ هەموو وابەستەییەکی X → Y کە بێبایەخ نەبێت، X دەبێت بناسێنێت. 3NF ڕێگە بە یەک بەدەرکردن دەدات: کاتێک Y بێت، پێویست ناکات X بێت. BCNF ئەو بەدەرکردنە لادەبات. چوار خشتەکەی زانکۆکەمان پێشتر لە BCNFدان: لە هەریەکەیاندا تاکە کلیلی خودی خشتەکەیە.
Here is a table that is in 3NF but not in BCNF. The college gives students extra tutoring. Each student has one tutor per subject, and each tutor teaches only one subject:
ئەمە خشتەیەکە کە لە 3NFدایە بەڵام لە BCNFدا نییە. کۆلێژەکە وانەی بەهێزکردن بە قوتابییەکان دەدات. هەر قوتابییەک بۆ هەر بابەتێک یەک ڕاهێنەری هەیە و هەر ڕاهێنەرێک تەنها یەک بابەت دەڵێتەوە:
student_no | subject | tutor |
|---|---|---|
| 2024-0137 | Databases | Hana |
| 2024-0137 | Programming | Soran |
| 2024-0152 | Databases | Hana |
| 2024-0188 | Databases | Rezan |
- Candidate keys:
(student_no, subject)and(student_no, tutor). All three columns are prime. The two keys have several columns each and overlap (both containstudent_no): that is the only shape in which a 3NF table can fail BCNF. tutor → subject:tutoris not a super key. 3NF accepts it (subject is prime); BCNF does not.- The anomaly: 'Hana teaches Databases' is stored in two rows. If Rezan's only student leaves, the database forgets which subject Rezan teaches.
- The BCNF split:
tutor_subject(tutor, subject)with keytutor, andstudent_tutor(student_no, tutor)with key(student_no, tutor).
- :
(student_no, subject)و(student_no, tutor). هەر سێ سەرەتایین. هەر یەکێک لە دوو کلیلەکە چەند هەیە و بەسەر یەکدا دەکەونەوە (هەردووکیانstudent_noـیان تێدایە): ئەمە تاکە شێوەیە کە خشتەیەکی 3NF تێیدا BCNF دەشکێنێت. tutor → subject:tutorنییە. 3NF وەری دەگرێت (subject سەرەتاییە)؛ BCNF وەری ناگرێت.- ناڕێکییەکە: «هانا Databases دەڵێتەوە» لە دوو هەڵگیراوە. ئەگەر تاکە قوتابیی ڕێزان بڕوات، لە بیری دەچێت ڕێزان چ بابەتێک دەڵێتەوە.
- لەتکردنی BCNF:
tutor_subject(tutor, subject)بە کلیلیtutorوstudent_tutor(student_no, tutor)بە کلیلی(student_no, tutor).
Formal 2NF and 3NF with candidate keys and prime attributes, the loophole 3NF leaves, and how BCNF closes it: every determinant must be a key.
پێناسەی فەرمیی و بە و ، کەلێنی سێیەمیان و چارەسەرەکەی : هەر دەبێت بێت.
Whole video: why a 3NF table can still repeat facts and what BCNF demands. The example at 8:22 is weak (the author's correction): a wrong Release_Year shows the conflict.
هەموو ڤیدیۆکە: بۆچی لە هێشتا دەتوانێت هەمان ڕاستییەکان دووبارە بکاتەوە و چی داوا دەکات. نموونەکەی 8:22 لاوازە (ڕاستکردنەوەی خودی دروستکەری ڤیدیۆکە): هەڵە بۆ Release_Year ناکۆکییەکە پیشان دەدات.
Fourth normal form (4NF), brieflyشێوەی نۆرماڵی چوارەم (4NF)، بە کورتی
A table is in fourth normal form (4NF) when it is in BCNF and does not hold two or more independent lists about the same thing (no except on a key).
خشتەیەک لە (4NF) دەبێت کاتێک لە BCNFـدا بێت و دوو لیستی سەربەخۆ یان زیاتر دەربارەی هەمان شت هەڵنەگرێت (هیچ نەبێت جگە لە سەر کلیل).
BCNF is about single facts. 4NF is about lists. Hana, a lecturer, sits on two committees (Exams, Library) and teaches two courses (DB101, WP101). The committees have nothing to do with the courses. Put both lists into one table and every committee must be paired with every course:
BCNF دەربارەی ڕاستیی تاکە. 4NF دەربارەی لیستەکانە. هانا، کە مامۆستایە، ئەندامی دوو لیژنەیە (تاقیکردنەوە، کتێبخانە) و دوو وانە دەڵێتەوە (DB101، WP101). لیژنەکان هیچ پەیوەندییەکیان بە وانەکانەوە نییە. ئەگەر هەردوو لیستەکە بخەیتە یەک ، دەبێت هەموو لیژنەیەک لەگەڵ هەموو وانەیەکدا جووت بکرێت:
lecturer | committee | course |
|---|---|---|
| Hana | Exams | DB101 |
| Hana | Exams | WP101 |
| Hana | Library | DB101 |
| Hana | Library | WP101 |
- Redundancy: 'Hana – Exams' is stored twice, once for each course.
- Anomaly: when Hana starts teaching a third course, two rows must be added, one for each committee. Store only one, and the table suggests the Library committee has something to do with the course.
- The other ways are worse: filling the gaps with NULLs ('Hana, Exams, NULL') puts NULL into the key, and pairing each committee with just one course invents a link that does not exist.
- دووبارەبوونەوە: «هانا – تاقیکردنەوە» دوو جار هەڵگیراوە، بۆ هەر وانەیەک جارێک.
- ناڕێکی: کاتێک هانا دەست بە وتنەوەی وانەی سێیەم دەکات، دەبێت دوو زیاد بکرێت، بۆ هەر لیژنەیەک یەکێک. ئەگەر تەنها یەکێکیان هەڵبگریت، خشتەکە وا پیشان دەدات کە لیژنەی کتێبخانە پەیوەندیی بە وانەکەوە هەیە.
- ڕێگاکانی تر خراپترن: پڕکردنەوەی بۆشاییەکان بە NULL («هانا، تاقیکردنەوە، NULL») NULL دەخاتە ناو کلیلەوە و جووتکردنی هەر لیژنەیەک لەگەڵ تەنها یەک وانەدا بەستنەوەیەک دادەهێنێت کە بوونی نییە.
Textbooks call this a multivalued dependency, written lecturer →→ committee: one lecturer fixes a whole set of committees, whatever the courses. The rule of 4NF: a table is in BCNF and holds no two independent lists like this.
کتێبەکان بەمە دەڵێن ، کە بەم شێوەیە دەنووسرێت lecturer →→ committee: یەک مامۆستا کۆمەڵێکی تەواوی لیژنەکان دیاری دەکات، هەر وانەیەک بێت. ڕێسای 4NF: خشتەکە لە BCNFدایە و دوو لیستی سەربەخۆی لەم جۆرە هەڵناگرێت.
Fourth normal form (4NF), brieflyشێوەی نۆرماڵی چوارەم (4NF)، بە کورتی
The 4NF split, and 5NF in one sentenceلەتکردنی 4NF و 5NF لە یەک ڕستەدا
The fix is one table for each independent list. Both keys are the whole row:
چارەسەرەکە یەک بۆ هەر لیستێکی سەربەخۆ. کلیلی هەردووکیان هەموو :
lecturer | committee |
|---|---|
| Hana | Exams |
| Hana | Library |
lecturer | course |
|---|---|
| Hana | DB101 |
| Hana | WP101 |
Four rows became , and a third course now needs one new row. In E-R terms the two lists are two binary relationships, LECTURER–COMMITTEE and LECTURER–COURSE, not one ternary relationship: use a ternary only when the three things really belong together, as in a prescription.
چوار بوونە و وانەی سێیەم ئێستا تەنها یەک نوێی پێویستە. بە زمانی ، دوو لیستەکە دوو دووانین، LECTURER–COMMITTEE و LECTURER–COURSE، نەک یەک پەیوەندیی سێیانی: تەنها کاتێک بەکار بهێنە کە سێ شتەکە بە ڕاستی پێکەوە بن، وەک لە ڕەچەتەیەکدا.
Splitting without losing anythingلەتکردن بەبێ لەدەستدانی هیچ شتێک
Every split must be reversible: when the new tables are joined again on their shared column (a natural join), we must get back exactly the original rows — no fewer, and no extra ones. Such a split is called lossless. A simple rule keeps it safe: the shared column must be a key of at least one of the new tables. In our steps, student_no is the key of student, course_code of course, and dept_code of department.
هەموو لەتکردنێک دەبێت بگەڕێتەوە: کاتێک خشتە نوێیەکان دووبارە لەسەر هاوبەشەکەیان پێکەوە دەبەسترێنەوە (لێکبەستنی سروشتی)، دەبێت ڕێک ئەسڵییەکان وەربگرینەوە — نە کەمتر و نە زیادە. لەتکردنێکی وا پێی دەوترێت lossless (بێ لەدەستدان). ڕێسایەکی سادە دەیپارێزێت: هاوبەشەکە دەبێت کلیلی بەلایەنی کەمەوە یەکێک لە خشتە نوێیەکان بێت. لە هەنگاوەکانماندا student_no کلیلی studentـە، course_code کلیلی course و dept_code کلیلی department.
A bad split shows why. Two different students are both called Aram Kamal: 2024-0137 in CS and 2025-0311 in SE. If we split them into (student_no, student_name) and (student_name, dept_code), the shared column student_name is a key of neither table. Joining again on the name gives four rows, and two of them are false:
لەتکردنێکی خراپ هۆکارەکە پیشان دەدات. دوو قوتابیی جیاواز هەردووکیان ناویان ئارام کەمالە: 2024-0137 لە CS و 2025-0311 لە SE. ئەگەر بیانکەین بە (student_no, student_name) و (student_name, dept_code)، هاوبەشەکە، student_name، کلیلی هیچ کامیان نییە. دووبارە بەستنەوەیان لەسەر ناو چوار دەدات و دووانیان هەڵەن:
student_no | student_name | dept_code | True?ڕاستە؟ |
|---|---|---|---|
| 2024-0137 | Aram Kamal | CS | yesبەڵێ |
| 2024-0137 | Aram Kamal | SE | no — inventedنەخێر — دەستکرد |
| 2025-0311 | Aram Kamal | CS | no — inventedنەخێر — دەستکرد |
| 2025-0311 | Aram Kamal | SE | yesبەڵێ |
Normalization in real lifeنۆرماڵکردن لە ژیانی ڕاستەقینەدا
- When: normalization belongs to the logical design step of the database development life cycle, after the E-R diagram has been turned into tables.
- Together with E-R modelling: the E-R diagram gives the big picture – which entities there are and how they relate (the macro view). Normalization checks each table in detail (the micro view) and may reveal an entity the diagram missed, such as
department. Designers use both, and both start from the business rules. - How far: most everyday databases (a university, a shop, a bank) are designed to 3NF or BCNF. Higher normal forms (4NF, 5NF) exist for rarer problems, such as two independent lists in one table (4NF, briefly).
- Denormalization: large reporting systems and data warehouses sometimes store repeated data on purpose, so that big questions need fewer joins. This is a conscious choice made after normalizing, not a reason to skip it.
- Keys stay central: every step of normalization creates new keys and foreign keys. If you are not sure about keys, go back to Database keys.
- کەی: سەر بە هەنگاوی دیزاینی لۆجیکیـە لە ، دوای ئەوەی کرا بە خشتە.
- لەگەڵ : وێنە گەورەکە دەدات – و چۆنیەتی پەیوەندییان پێکەوە (تێڕوانینی گەورە). هەر بە وردی دەپشکنێت (تێڕوانینی ورد) و لەوانەیە دەربخات کە هێڵکارییەکە لە بیری کردووە، وەک
department. دیزاینەران هەردووکیان بەکار دەهێنن و هەردووکیان لە یاساکانی کارەکەوە دەست پێدەکەن. - تا کوێ: زۆربەی ڕۆژانە (زانکۆ، دوکان، بانک) تا 3NF یان BCNF دیزاین دەکرێن. بەرزتر (4NF، 5NF) بۆ کێشەی دەگمەنتر هەن، وەک دوو لیستی سەربەخۆ لە یەک خشتەدا (4NF، بە کورتی).
- نۆرماڵنەکردنەوە (denormalization): سیستەمە گەورەکانی ڕاپۆرت و کۆگاکانی هەندێک جار بە ئەنقەست دووبارە هەڵدەگرن، بۆ ئەوەی پرسیارە گەورەکان کەمتریان پێویست بێت. ئەمە هەڵبژاردنێکی بەئاگایە کە دوای دەکرێت، نەک هۆکارێک بۆ وازهێنان لێی.
- لە ناوەندەوە دەمێننەوە: هەموو هەنگاوێکی نوێ و نوێ دروست دەکات. ئەگەر دڵنیا نیت لە ، بگەڕێوە بۆ کلیلەکانی بنکەدراوە.
Common mistakesهەڵە باوەکان
| Mistakeهەڵە | Why it is wrongبۆچی هەڵەیە | Do this insteadلە جیاتی ئەوە ئەمە بکە |
|---|---|---|
| Finding dependencies from today's rowsدۆزینەوەی وابەستەییەکان لە ئەمڕۆوە | A dependency can hold by chance (student_name → student_no)وابەستەییەک دەکرێت بە ڕێکەوت ڕاست بێت (student_name ← student_no) | Ask what the rules of the organisation guaranteeپرسیار بکە ڕێساکانی دامەزراوەکە زامنی چی دەکەن |
Replacing a list cell with course1, course2, course3گۆڕینی خانەی لیست بە course1، course2، course3 | Still a repeating group: NULLs, and no room for a fourth courseهێشتا کۆمەڵە ستوونێکی دووبارەبووەوەیە: NULL و جێ بۆ وانەی چوارەم نییە | One row per courseیەک بۆ هەر وانەیەک |
| Looking for partial dependencies in a table with a one-column keyگەڕان بەدوای لە خشتەیەکدا کە کلیلەکەی یەک | With a one-column key there is no 'part' of the keyکاتێک کلیل یەک بێت، «بەشێک»ی کلیل نییە | Check those tables for transitive dependencies (3NF)ئەو خشتانە بۆ بپشکنە (3NF) |
| Splitting on a column that is not a key of either new tableلەتکردن لەسەر کە کلیلی هیچ کام لە خشتە نوێیەکان نییە | The join creates false rows (lossy split) هەڵە دروست دەکات (لەتکردن بە لەدەستدان) | Split on a determinant; make it the new table's keyلەسەر لەت بکە؛ بیکە بە کلیلی خشتە نوێیەکە |
| Forgetting the foreign key after a splitلەبیرچوونی دوای لەتکردن | The tables can no longer be joined safelyئیتر خشتەکان بە سەلامەتی پێکەوە نابەسترێنەوە | Keep the determinant in the old table as a foreign key لە خشتە کۆنەکەدا وەک بهێڵەوە |
Moving the price paid into the book tableگواستنەوەی نرخی دراو بۆ خشتەی book | Prices change; old sales must keep the price of their dayنرخەکان دەگۆڕێن؛ فرۆشتنە کۆنەکان دەبێت نرخی ڕۆژی خۆیان بهێڵنەوە | Keep unit_price in the order line (it depends on the whole sale)unit_price لە دێڕی داواکارییەکەدا بهێڵەوە (پشت بە هەموو فرۆشتنەکە دەبەستێت) |
| Calling BCNF the 'fourth normal form'ناونانی BCNF بە «» | BCNF sits between 3NF and 4NF and is about determinants; 4NF is about independent listsBCNF لە نێوان 3NF و 4NFدایە و دەربارەی ؛ 4NF دەربارەی لیستی سەربەخۆیە | Learn the order 1NF, 2NF, 3NF, BCNF, 4NF, 5NFڕیزبەندییەکە فێر ببە: 1NF، 2NF، 3NF، BCNF، 4NF، 5NF |
Exercisesڕاهێنانەکان
A bookshop in Erbil keeps its order lines in one table: order_line(order_no, order_date, customer_id, customer_name, isbn, book_title, quantity, unit_price). The rules: an order has one date and one customer; a customer has one name; a book (ISBN) has one title; the price paid is written for each line, because prices change. The key is (order_no, isbn). (a) Write the functional dependencies. (b) Bring the table to 2NF. (c) Bring it to 3NF.
کتێبفرۆشێک لە هەولێر دێڕەکانی داواکارییەکانی لە یەک خشتەدا هەڵدەگرێت: order_line(order_no, order_date, customer_id, customer_name, isbn, book_title, quantity, unit_price). ڕێساکان: داواکارییەک یەک ڕێکەوت و یەک کڕیاری هەیە؛ کڕیارێک یەک ناوی هەیە؛ کتێبێک (ISBN) یەک ناونیشانی هەیە؛ نرخی دراو بۆ هەر دێڕێک دەنووسرێت، چونکە نرخەکان دەگۆڕێن. کلیلەکە (order_no, isbn)ـە. (أ) بنووسە. (ب) خشتەکە بگەیەنە 2NF. (ج) بیگەیەنە 3NF.
Hintئاماژە
Look at what each part of the key decides on its own, then look for a non-key column that decides another one.
سەیر بکە هەر بەشێکی کلیلەکە بە تەنها چی دیاری دەکات، پاشان بەدوای ناکلیلیدا بگەڕێ کە یەکێکی تر دیاری دەکات.
Show answerوەڵامەکە پیشان بدە
- (a)
order_no → order_date, customer_id;customer_id → customer_name;isbn → book_title;order_no, isbn → quantity, unit_price. - (b) 2NF:
orders(order_no, order_date, customer_id, customer_name),book(isbn, book_title),order_line(order_no, isbn, quantity, unit_price). - (c) 3NF:
customer_namedepends onorder_noonly throughcustomer_id, so:orders(order_no, order_date, customer_id),customer(customer_id, customer_name),book(isbn, book_title),order_line(order_no, isbn, quantity, unit_price). unit_pricestays inorder_line: it is the price of this sale, so it depends on the whole key. A 'current price' column, if wanted, would go intobook.
- (أ)
order_no → order_date, customer_id؛customer_id → customer_name؛isbn → book_title؛order_no, isbn → quantity, unit_price. - (ب) 2NF:
orders(order_no, order_date, customer_id, customer_name)،book(isbn, book_title)،order_line(order_no, isbn, quantity, unit_price). - (ج) 3NF:
customer_nameتەنها لە ڕێگەیcustomer_idـەوە پشت بەorder_noدەبەستێت، بۆیە:orders(order_no, order_date, customer_id)،customer(customer_id, customer_name)،book(isbn, book_title)،order_line(order_no, isbn, quantity, unit_price). unit_priceلەorder_lineدا دەمێنێتەوە: نرخی ئەم فرۆشتنەیە، بۆیە پشت بە هەموو کلیلەکە دەبەستێت. «نرخی ئێستا»، ئەگەر پێویست بێت، دەچێتە ناوbook.
contact(student_no, full_name, phones) stores values such as '0750 000 0101, 0770 000 0102' in phones. Which normal form does it break? Redesign it.
contact(student_no, full_name, phones) نرخی وەک '0750 000 0101, 0770 000 0102' لە phonesدا هەڵدەگرێت. کام دەشکێنێت؟ دیزاینەکەی بگۆڕە.
Show answerوەڵامەکە پیشان بدە
It breaks 1NF: one cell holds two values. Use two tables: student(student_no, full_name) and student_phone(student_no, phone) with the key (student_no, phone) and student_no as a foreign key. A student may now have any number of phones.
1NF دەشکێنێت: یەک خانە دوو نرخ هەڵدەگرێت. دوو خشتە بەکار بهێنە: student(student_no, full_name) و student_phone(student_no, phone) بە کلیلی (student_no, phone) و student_no وەک . ئێستا قوتابییەک دەتوانێت هەر چەند ژمارەیەکی هەبێت.
exam(student_no, course_code, grade, course_lecturer, lecturer_office) has the key (student_no, course_code). Classify each dependency: (a) student_no, course_code → grade (b) course_code → course_lecturer (c) course_lecturer → lecturer_office.
exam(student_no, course_code, grade, course_lecturer, lecturer_office) کلیلی (student_no, course_code)ـی هەیە. هەر وابەستەییەک پۆلێن بکە: (أ) student_no, course_code → grade (ب) course_code → course_lecturer (ج) course_lecturer → lecturer_office.
Show answerوەڵامەکە پیشان بدە
- (a) Full: grade needs the whole key.
- (b) Partial: course_lecturer depends on only part of the key — breaks 2NF.
- (c) Transitive: lecturer_office depends on the key through a non-key column — breaks 3NF. (Through course_lecturer it also depends on course_code alone, so the 2NF step first moves it into
course(course_code, course_lecturer, lecturer_office); the 3NF step then splits offlecturer.) Result:exam(student_no, course_code, grade),course(course_code, course_lecturer),lecturer(course_lecturer, lecturer_office).
- (أ) تەواو: نمرە پێویستی بە هەموو کلیلەکە هەیە.
- (ب) بەشەکی: course_lecturer تەنها پشت بە بەشێکی کلیلەکە دەبەستێت — 2NF دەشکێنێت.
- (ج) ناڕاستەوخۆ: lecturer_office لە ڕێگەی ناکلیلییەوە پشت بە کلیلەکە دەبەستێت — 3NF دەشکێنێت. (لە ڕێگەی course_lecturerـەوە تەنها پشت بە course_codeـیش دەبەستێت، بۆیە هەنگاوی 2NF سەرەتا دەیگوازێتەوە بۆ
course(course_code, course_lecturer, lecturer_office)؛ پاشان هەنگاوی 3NF خشتەیlecturerجیا دەکاتەوە.) ئەنجام:exam(student_no, course_code, grade)،course(course_code, course_lecturer)،lecturer(course_lecturer, lecturer_office).
A construction company in Erbil prints this report every month. The rules: a project has one name; an employee has one name and one job class; the charge per hour depends only on the job class; the hours belong to one employee on one project. (a) Write the functional dependencies. (b) Bring the report to 1NF. (c) Then to 2NF and (d) to 3NF. (e) Are the 3NF tables also in 4NF?
کۆمپانیایەکی بیناسازی لە هەولێر هەموو مانگێک ئەم ڕاپۆرتە چاپ دەکات. یاساکان: هەر پرۆژەیەک یەک ناوی هەیە؛ هەر فەرمانبەرێک یەک ناو و یەک پۆلی کاری هەیە؛ کرێی هەر کاتژمێرێک تەنها پشت بە پۆلی کار دەبەستێت؛ کاتژمێرەکان هی یەک فەرمانبەرن لە یەک پرۆژەدا. (أ) بنووسە. (ب) ڕاپۆرتەکە بگەیەنە 1NF. (ج) پاشان 2NF و (د) 3NF. (هـ) ئایا خشتەکانی 3NF لە 4NFیشدان؟
proj_num | proj_name | emp_num | emp_name | job_class | chg_hour_iqd | hours |
|---|---|---|---|---|---|---|
| 15 | Ankawa School | 101 | Aram Kamal | Electrical Engineer | 85,000 | 23.8 |
| 103 | Shilan Omar | Electrical Engineer | 85,000 | 19.4 | ||
| 106 | Dilan Hama | Programmer | 35,000 | 12.6 | ||
| 18 | Duhok Clinic | 101 | Aram Kamal | Electrical Engineer | 85,000 | 17.0 |
| 105 | Karwan Aziz | Database Designer | 105,000 | 35.7 | ||
| 114 | Hana Rauf | Programmer | 35,000 | 24.6 |
Hintئاماژە
Start from the blank cells: they hide a repeating group. Then ask what each part of the key decides on its own.
لە خانە بەتاڵەکانەوە دەست پێبکە: کۆمەڵەیەکی دووبارەبووەوەیان تێدا شاردراوەتەوە. پاشان بپرسە هەر بەشێکی کلیلەکە بە تەنها چی دیاری دەکات.
Show answerوەڵامەکە پیشان بدە
(a) proj_num → proj_name; emp_num → emp_name, job_class; job_class → chg_hour_iqd; proj_num, emp_num → hours.
(أ) proj_num → proj_name؛ emp_num → emp_name, job_class؛ job_class → chg_hour_iqd؛ proj_num, emp_num → hours.
- (b) 1NF: write the project number and name on every line, so every cell has a value. The key is
(proj_num, emp_num). - (c) 2NF – remove the partial dependencies:
project(proj_num, proj_name),employee(emp_num, emp_name, job_class, chg_hour_iqd),assignment(proj_num, emp_num, hours). - (d) 3NF –
chg_hour_iqddepends onemp_numonly throughjob_class, so split it off:job(job_class, chg_hour_iqd)andemployee(emp_num, emp_name, job_class). Result:project,employee,job,assignment. - (e) Yes: no table holds two independent lists, and in each one the only determinant is its key (so they are in BCNF too).
- (ب) 1NF: ژمارە و ناوی پرۆژەکە لە هەموو دێڕێکدا بنووسە، بۆ ئەوەی هەموو خانەیەک نرخی هەبێت. کلیلەکە
(proj_num, emp_num)ـە. - (ج) 2NF – لاببە:
project(proj_num, proj_name)،employee(emp_num, emp_name, job_class, chg_hour_iqd)،assignment(proj_num, emp_num, hours). - (د) 3NF –
chg_hour_iqdتەنها لە ڕێگەیjob_classـەوە پشت بەemp_numدەبەستێت، بۆیە جیای بکەرەوە:job(job_class, chg_hour_iqd)وemployee(emp_num, emp_name, job_class). ئەنجام:project،employee،job،assignment. - (هـ) بەڵێ: هیچ خشتەیەک دوو لیستی سەربەخۆ هەڵناگرێت و لە هەر یەکێکیاندا تاکە کلیلەکەیەتی (بۆیە لە BCNFیشدان).
A university keeps its study programmes in one spreadsheet. Every major belongs to one department, and every department to one college. Which facts repeat? Split the sheet into tables and give the relationships between them.
زانکۆیەک پسپۆڕییەکانی خۆی لە یەک هەڵدەگرێت. هەر پسپۆڕییەک سەر بە یەک بەشە و هەر بەشێکیش سەر بە یەک کۆلێژ. کام ڕاستییانە دووبارە دەبنەوە؟ بکە بە چەند و نێوانیان بنووسە.
college | department | major |
|---|---|---|
| Science | Biology | Biology |
| Science | Biology | Microbiology |
| Science | Computer Science | Computer Science |
| Science | Computer Science | Information Systems |
| Science | Computer Science | Networks |
| Administration and Economics | Economics | Economics |
Show answerوەڵامەکە پیشان بدە
'Biology belongs to Science' is stored twice and 'Computer Science belongs to Science' three times. The dependencies are major → department and department → college: a transitive chain. Three tables remove it: college(college_name), department(dept_name, college_name) and major(major_name, dept_name), where college_name and dept_name become foreign keys. In E-R terms: COLLEGE 1:N DEPARTMENT and DEPARTMENT 1:N MAJOR.
«بایۆلۆجی سەر بە زانستە» دوو جار هەڵگیراوە و «زانستی کۆمپیوتەر سەر بە زانستە» سێ جار. وابەستەییەکان major → department و department → collegeـن: زنجیرەیەکی ناڕاستەوخۆ. سێ لای دەبەن: college(college_name)، department(dept_name, college_name) و major(major_name, dept_name)، کە college_name و dept_name دەبنە . بە زمانی : COLLEGE 1:N DEPARTMENT و DEPARTMENT 1:N MAJOR.
Summary and reviewپوختە و پێداچوونەوە
- Normalization splits tables so that each fact is stored once; it removes insertion, deletion and modification anomalies.
- A functional dependency X → Y: rows that agree on X agree on Y. It comes from the rules of the real world.
- 1NF: one atomic value per cell. 2NF: no partial dependency on a key. 3NF: no transitive dependency. BCNF: every determinant is a super key.
- Split on a determinant and make it the key of the new table: the split is lossless, and it leaves a foreign key behind.
- خشتەکان لەت دەکات بۆ ئەوەی هەر ڕاستییەک یەک جار هەڵبگیرێت؛ ، و لادەبات.
- X → Y: ئەو لە Xدا وەک یەکن لە Yیشدا وەک یەکن. لە ڕێساکانی جیهانی ڕاستەقینەوە دێت.
- 1NF: یەک لە هەر خانەیەکدا. 2NF: بێ لەسەر کلیل. 3NF: بێ . BCNF: هەموو .
- لەسەر لەت بکە و بیکە بە کلیلی خشتە نوێیەکە: لەتکردنەکە بێ لەدەستدان دەبێت و بەجێ دەهێڵێت.
What does 'X determines Y' mean?«X، Y دیاری دەکات» واتای چییە؟
Whenever two rows have the same X, they also have the same Y (a functional dependency X → Y).
هەر کاتێک دوو هەمان Xیان هەبێت، هەمان Yـیشیان هەیە ( X → Y).
Which tables can break 2NF?کام خشتانە دەتوانن 2NF بشکێنن؟
Only tables with a composite candidate key: a non-prime column may then depend on just part of it.
تەنها ئەو خشتانەی لێکدراویان هەیە: ئەوکات ناسەرەتایی دەکرێت تەنها پشت بە بەشێکی ببەستێت.
Why move dept_name out of student?بۆچی dept_name لە student دەردەهێنرێت؟
Because it depends on student_no only through dept_code (a transitive dependency). It is a fact about the department, so it belongs in department.
چونکە تەنها لە ڕێگەی dept_codeـەوە پشت بە student_no دەبەستێت (). ڕاستییەکە دەربارەی بەشەکە، بۆیە جێگەی لە departmentـدایە.
How can you tell that a split is lossless?چۆن دەزانیت لەتکردنێک بێ لەدەستدانە؟
The shared column is a key of at least one of the new tables, so joining them gives back exactly the original rows.
هاوبەشەکە کلیلی بەلایەنی کەمەوە یەکێک لە خشتە نوێیەکانە، بۆیە بەستنەوەیان ڕێک ئەسڵییەکان دەگەڕێنێتەوە.
Videoڤیدیۆ
Watch a videoسەیری ڤیدیۆیەک بکە
A video that viewers liked a lot and praised in their comments, chosen for this lesson.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.
Step by step from an unnormalized table to first, second and third normal form, with the anomalies each step removes and a BCNF note.
پلەبەپلە لە نۆرماڵنەکراوەوە تا ، و ، لەگەڵ ئەو ناڕێکییانەی هەر هەنگاوێک لایان دەبات و تێبینییەک دەربارەی .
Plays 0:00-20:29: 1NF, 2NF and 3NF, with a BCNF note. The video says 'primary key'; the lesson's exact rule says 'candidate key'. With one key they are the same.
لە 0:00 تا 20:29 پەخش دەبێت: ، و ، لەگەڵ تێبینییەک دەربارەی . ڤیدیۆکە دەڵێت «»، بەڵام ڕێسا وردەکەی وانەکە دەڵێت «». ئەگەر تەنها یەک هەبێت، هەردووکیان یەک شتن.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Relational Algebra and Relational Calculusجەبری پەیوەندیدار و ژمێرکاریی پەیوەندیدار
Related lecturesوانە پەیوەندیدارەکان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- Microsoft Support: Database design basics (normalizing your tables)
- Silberschatz, Korth and Sudarshan, Database System Concepts, 7th ed. — Chapter 7 slides: Relational Database Design (functional dependencies, BCNF, 3NF, lossless decomposition, first normal form)
- S. Bressan (after T. W. Ling), CS4221 Normal Forms, National University of Singapore (2NF, 3NF, BCNF definitions)
- William Kent, A Simple Guide to Five Normal Forms in Relational Database Theory (Communications of the ACM, 1983)
- Microsoft Learn: Understand star schema — Normalization vs. denormalization
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.