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 بە کورتی — هەمووی لەسەر یەک پەڕەی تۆمارکردنی زانکۆ.

22 min read24 خولەک خوێندنەوە · 19 stepsهەنگاو

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?بۆچی نۆرماڵکردن؟

Definitionپێناسە

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): هەموو شتێکی تر یەک جار هەڵدەگیرێت.

The shopkeeper's notebookدەفتەری دوکاندار

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:

نووسینگەی کۆلێژێک لە سلێمانی تۆمارکردنەکانی یەک وەرز لە یەک هەڵدەگرێت. بۆ هەر قوتابییەک یەک هەیە و هەموو وانەکانی قوتابییەک لە یەک خانەدا نووسراون:

registration sheet — not normalizedپەڕەی تۆمارکردن — نۆرماڵ نەکراوە
student_nostudent_namedept_codedept_namecourses
2024-0137Aram KamalCSComputer ScienceDB101 Database Fundamentals (3) B; WP101 Web Programming (3) A
2024-0152Shilan OmarITInformation TechnologyDB101 Database Fundamentals (3) C
2024-0188Karwan AzizCSComputer ScienceDB201 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⁩.

Quick checkپشکنینی خێراWhat is the main problem of the courses cell?کێشەی سەرەکیی خانەی courses چییە؟

Step 1: first normal form (1NF)هەنگاوی ١: شێوەی نۆرماڵی یەکەم ⁦(1NF)⁩

Definitionپێناسە

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.

  1. Give every course its own row. Copy the student's data into each of their rows.

    هەموو وانەیەک تایبەت بە خۆی بدەرێ. قوتابییەکە بۆ هەریەکە لە کۆپی بکە.

  2. Split the course text into separate columns: course_code, course_title, credits, grade.

    دەقی وانەکە بۆ چەند جیا لەت بکە: course_code، course_title، credits، grade.

  3. Choose the key. A student has many rows now, so student_no alone repeats. (student_no, course_code) is unique: it becomes the primary key.

    کلیلەکە هەڵبژێرە. ئێستا قوتابییەک چەند هەیە، بۆیە student_no بە تەنها دووبارە دەبێتەوە. (student_no, course_code) یەکتایە: دەبێتە .

registration — in 1NF; key (student_no, course_code)خشتەی registration — لە ⁦1NF⁩دا؛ کلیل ⁦(student_no, course_code)⁩
student_nocourse_codestudent_namedept_codedept_namecourse_titlecreditsgrade
2024-0137DB101Aram KamalCSComputer ScienceDatabase Fundamentals3B
2024-0137WP101Aram KamalCSComputer ScienceWeb Programming3A
2024-0152DB101Shilan OmarITInformation TechnologyDatabase Fundamentals3C
2024-0188DB201Karwan AzizCSComputer ScienceDatabase Administration3A
2024-0188WP101Karwan AzizCSComputer ScienceWeb Programming3B
Quick checkپشکنینی خێراWhich design is in first normal form?کام دیزاین لە ؟

1NF is not enough: the anomalies are still there⁦1NF⁩ بەس نییە: ناڕێکییەکان هێشتا ماون

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_no is 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.

بۆ لابردنی ئەم ناڕێکییانە پێویستمان بە ڕێگایەکی ورد هەیە بۆ ئەوەی بڵێین کام لەگەڵ کامیاندا دەڕوات. ئەو ئامرازە .

Quick checkپشکنینی خێراThe college wants to store the new course AI301 before anyone registers. Which anomaly stops it in the 1NF table?کۆلێژەکە دەیەوێت وانەی نوێی ⁦AI301⁩ پێش ئەوەی کەس تۆمار بکات هەڵبگرێت. لە خشتە ⁦1NF⁩ـەکەدا کام ناڕێکی ڕێگەی لێ دەگرێت؟

Functional dependencyوابەستەیی فەنکشنی

Definitionپێناسە

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_code and college_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.
Quick checkپشکنینی خێراIn course(course_code, course_title, credits), which functional dependency must hold?لە course(course_code, course_title, credits)دا، کام دەبێت ڕاست بێت؟

Functional dependencyوابەستەیی فەنکشنی

The dependencies of our tableوابەستەییەکانی خشتەکەمان

The college's rules give four functional dependencies for registration:

ڕێساکانی کۆلێژەکە چوار بۆ registration دەدەن:

  1. student_no → student_name, dept_code — a student has one name and one department.
  2. dept_code → dept_name — a department code has one name.
  3. course_code → course_title, credits — a course has one title and one number of credits.
  4. student_no, course_code → grade — a grade belongs to one student in one course.
  1. student_no → student_name, dept_code — قوتابییەک یەک ناو و یەک بەشی هەیە.
  2. dept_code → dept_name — کۆدی بەشێک یەک ناوی هەیە.
  3. course_code → course_title, credits — وانەیەک یەک ناونیشان و یەک ژمارەی یەکەی هەیە.
  4. student_no, course_code → grade — نمرەیەک هی یەک قوتابییە لە یەک وانەدا.
Dependency diagram of the 1NF table registration. The key columns student_no and course_code are underlined. Orange arrows (partial dependency): from student_no to student_name and dept_code, and from course_code to course_title and credits. A purple arrow (transitive dependency): from dept_code to dept_name. A green arrow (full dependency): from student_no and course_code together to grade. Legend: partial dependency, on only part of the key, breaks second normal form; transitive dependency, through a non-key column, breaks third normal form; full dependency, on the whole key, is how every non-key column should depend.هێڵکاریی وابەستەییەکانی خشتەی 1NFـی registration. ستوونە کلیلییەکان student_no و course_code هێڵیان بە ژێردا کێشراوە. تیرە پرتەقاڵییەکان (وابەستەیی بەشەکی): لە student_noـەوە بۆ student_name و dept_code و لە course_codeـەوە بۆ course_title و credits. تیرێکی مۆر (وابەستەیی ناڕاستەوخۆ): لە dept_codeـەوە بۆ dept_name. تیرێکی سەوز (وابەستەیی تەواو): لە student_no و course_code پێکەوە بۆ grade. ڕێنمایی: وابەستەیی بەشەکی، تەنها لەسەر بەشێکی کلیلەکە، شێوەی نۆرماڵی دووەم دەشکێنێت؛ وابەستەیی ناڕاستەوخۆ، لە ڕێگەی ستوونێکی ناکلیلییەوە، شێوەی نۆرماڵی سێیەم دەشکێنێت؛ وابەستەیی تەواو، لەسەر هەموو کلیلەکە، ئەو شێوەیەیە کە هەموو ستوونێکی ناکلیلی دەبێت وابەستە بێت.
Arrows above the columns: partial dependencies. Below: a transitive and a full dependency.تیرەکانی سەرەوەی : . خوارەوە: و وابەستەییەکی تەواو.CêIT

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⁩ جۆری دووەم.

Quick checkپشکنینی خێراdept_name depends on student_no only through dept_code. What kind of dependency is that?dept_name تەنها لە ڕێگەی dept_codeـەوە پشت بە student_no دەبەستێت. ئەمە چ جۆرە وابەستەییەکە؟

Step 2: second normal form (2NF)هەنگاوی ٢: شێوەی نۆرماڵی دووەم ⁦(2NF)⁩

Definitionپێناسە

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⁩دایە و هیچ تەنها پشت بە بەشێک لە نابەستێت. هەموو ناکلیلی دەبێت پشت بە هەموو کلیلەکە ببەستێت. خشتەیەک کە هەموو یەک بن ناتوانێت ئەم ڕێسایە بشکێنێت؛ تەنها خشتەکانی خاوەن دەتوانن.

  1. Find the partial dependencies: student_no → student_name, dept_code (and with it dept_name), and course_code → course_title, credits.

    بدۆزەوە: student_no → student_name, dept_code (و لەگەڵیدا dept_name) و course_code → course_title, credits.

  2. 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) and course(course_code, course_title, credits).

    هەر کۆمەڵەیەک بگوازەوە بۆ خشتەیەکی نوێ کە کلیلەکەی ئەو بەشەی کلیلە کۆنەکە بێت: student(student_no, student_name, dept_code, dept_name) و course(course_code, course_title, credits).

  3. 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 to student and course.

    ئەوەی پشت بە هەموو کلیلەکە دەبەستێت لە خشتە کۆنەکەدا بهێڵەوە: enrolment(student_no, course_code, grade). دوو کلیلییەکەی ئێستا هەروەها بۆ student و course.

Step 2: second normal form (2NF)هەنگاوی ٢: شێوەی نۆرماڵی دووەم ⁦(2NF)⁩

The three tables after 2NFسێ خشتەکە دوای ⁦2NF⁩

studentخشتەی student
student_nostudent_namedept_codedept_name
2024-0137Aram KamalCSComputer Science
2024-0152Shilan OmarITInformation Technology
2024-0188Karwan AzizCSComputer Science
courseخشتەی course
course_codecourse_titlecredits
DB101Database Fundamentals3
DB201Database Administration3
WP101Web Programming3
enrolment — key (student_no, course_code)خشتەی enrolment — کلیل ⁦(student_no, course_code)⁩
student_nocourse_codegrade
2024-0137DB101B
2024-0137WP101A
2024-0152DB101C
2024-0188DB201A
2024-0188WP101B

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دا نووسراوە.

Quick checkپشکنینی خێراWhy is enrolment(student_no, course_code, grade) in 2NF?بۆچی enrolment(student_no, course_code, grade) لە ⁦2NF⁩دایە؟

Step 3: third normal form (3NF)هەنگاوی ٣: شێوەی نۆرماڵی سێیەم ⁦(3NF)⁩

Definitionپێناسە

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: ناوی بەش ڕاستییەکە دەربارەی بەشەکە، نەک دەربارەی قوتابییەکە.

  1. Move the transitive part into a new table keyed by its determinant: department(dept_code, dept_name).

    بەشە ناڕاستەوخۆکە بگوازەوە بۆ خشتەیەکی نوێ کە کلیلەکەی بێت: department(dept_code, dept_name).

  2. 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).

departmentخشتەی department
dept_codedept_name
CSComputer Science
ITInformation 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⁩ یەک دەگۆڕێت.

Quick checkپشکنینی خێراstaff(staff_no, name, office_no, office_phone): each staff member has one office, and each office has one phone. Which normal form does it break?staff(staff_no, name, office_no, office_phone): هەر فەرمانبەرێک یەک ژووری کاری هەیە و هەر ژوورێک یەک تەلەفۆنی هەیە. کام دەشکێنێت؟

Step 3: third normal form (3NF)هەنگاوی ٣: شێوەی نۆرماڵی سێیەم ⁦(3NF)⁩

The whole road at a glanceهەموو ڕێگاکە بە یەک سەیرکردن

Four columns from left to right. Unnormalized: registration sheet(student_no, student_name, dept_code, dept_name, courses: code, title, credits, grade as a list). 1NF, one value in every cell: registration(student_no, course_code as key, student_name, dept_code, dept_name, course_title, credits, grade). 2NF, no partial dependencies: student(student_no, student_name, dept_code, dept_name), course(course_code, course_title, credits), enrolment(student_no FK, course_code FK, grade). 3NF, no transitive dependencies: student(student_no, student_name, dept_code FK), department(dept_code, dept_name), course(course_code, course_title, credits), enrolment(student_no FK, course_code FK, grade). Underlined = primary key. Every step splits a table; no fact is lost, and each fact ends up in one place.چوار ستوون لە چەپەوە بۆ ڕاست. نۆرماڵنەکراو: registration sheet(student_no، student_name، dept_code، dept_name، courses: کۆد، ناونیشان، یەکە، نمرە وەک لیست). 1NF، یەک نرخ لە هەموو خانەیەکدا: registration(student_no و course_code وەک کلیل، student_name، dept_code، dept_name، course_title، credits، grade). 2NF، بێ وابەستەیی بەشەکی: student(student_no، student_name، dept_code، dept_name)، course(course_code، course_title، credits)، enrolment(student_no FK، course_code FK، grade). 3NF، بێ وابەستەیی ناڕاستەوخۆ: student(student_no، student_name، dept_code FK)، department(dept_code، dept_name)، course(course_code، course_title، credits)، enrolment(student_no FK، course_code FK، grade). هێڵی بە ژێردا = کلیلی سەرەکی. هەر هەنگاوێک خشتەیەک لەت دەکات؛ هیچ ڕاستییەک ون نابێت و هەر ڕاستییەک لە یەک شوێندا دەمێنێتەوە.
From one sheet to four tables: the three steps of this lesson.لە یەک پەڕەوە بۆ چوار خشتە: سێ هەنگاوەکەی ئەم وانەیە.CêIT

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، پەڕەی داهاتوو).

04. Normalization in Access 2016 كردارى بەشكردن و باشكردنى خشتە لە ئەكسێسSiyamand Rashid · Kurdish (Sorani)کوردی (سۆرانی) · 18K viewsبینین · 634 likesلایک

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)⁩، بە کورتی

Definitionپێناسە

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دا نییە. کۆلێژەکە وانەی بەهێزکردن بە قوتابییەکان دەدات. هەر قوتابییەک بۆ هەر بابەتێک یەک ڕاهێنەری هەیە و هەر ڕاهێنەرێک تەنها یەک بابەت دەڵێتەوە:

tutoring — FDs: (student_no, subject) → tutor and tutor → subjectخشتەی tutoring — وابەستەییەکان: ⁦(student_no, subject)⁩ ← tutor و tutor → subject
student_nosubjecttutor
2024-0137DatabasesHana
2024-0137ProgrammingSoran
2024-0152DatabasesHana
2024-0188DatabasesRezan
  • Candidate keys: (student_no, subject) and (student_no, tutor). All three columns are prime. The two keys have several columns each and overlap (both contain student_no): that is the only shape in which a 3NF table can fail BCNF.
  • tutor → subject: tutor is 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 key tutor, and student_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).
Quick checkپشکنینی خێراWhat does BCNF demand that 3NF does not?BCNF داوای چی دەکات کە ⁦3NF⁩ داوای ناکات؟

Learn Boyce-Codd Normal Form (BCNF)Decomplexify · Englishئینگلیزی · 180K viewsبینین · 4.7K likesلایک

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)⁩، بە کورتی

Definitionپێناسە

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_duty — in BCNF, but not in 4NF⁦lecturer_duty⁩ — لە BCNFدایە، بەڵام لە ⁦4NF⁩دا نییە
lecturercommitteecourse
HanaExamsDB101
HanaExamsWP101
HanaLibraryDB101
HanaLibraryWP101
  • 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دایە و دوو لیستی سەربەخۆی لەم جۆرە هەڵناگرێت.

Quick checkپشکنینی خێراWhy is lecturer_duty not in 4NF, although it is in BCNF?بۆچی lecturer_duty لە ⁦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خشتەی lecturer_committee
lecturercommittee
HanaExams
HanaLibrary
lecturer_courseخشتەی lecturer_course
lecturercourse
HanaDB101
HanaWP101

Four rows became 2+22+2, 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.

چوار بوونە 2+22+2 و وانەی سێیەم ئێستا تەنها یەک نوێی پێویستە. بە زمانی ، دوو لیستەکە دوو دووانین، ⁦LECTURER–COMMITTEE⁩ و ⁦LECTURER–COURSE⁩، نەک یەک پەیوەندیی سێیانی: تەنها کاتێک بەکار بهێنە کە سێ شتەکە بە ڕاستی پێکەوە بن، وەک لە ڕەچەتەیەکدا.

Quick checkپشکنینی خێراA student has several phone numbers and several hobbies, and they have nothing to do with each other. Which design is in 4NF?قوتابییەک چەند ژمارە مۆبایلێکی هەیە و چەند حەزێکی هەیە و هیچ پەیوەندییەکیان پێکەوە نییە. کام دیزاین لە ⁦4NF⁩دایە؟

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، کلیلی هیچ کامیان نییە. دووبارە بەستنەوەیان لەسەر ناو چوار دەدات و دووانیان هەڵەن:

The join of a bad split — the false rows are marked لەتکردنێکی خراپ — هەڵەکان دیاری کراون
student_nostudent_namedept_codeTrue?ڕاستە؟
2024-0137Aram KamalCSyesبەڵێ
2024-0137Aram KamalSEno — inventedنەخێر — دەستکرد
2025-0311Aram KamalCSno — inventedنەخێر — دەستکرد
2025-0311Aram KamalSEyesبەڵێ
Quick checkپشکنینی خێراWe split student(student_no, student_name, dept_code, dept_name) into student(student_no, student_name, dept_code) and department(dept_code, dept_name). Is the split lossless?student(student_no, student_name, dept_code, dept_name) لەت دەکەین بۆ student(student_no, student_name, dept_code) و department(dept_code, dept_name). ئایا لەتکردنەکە بێ لەدەستدانە؟

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): سیستەمە گەورەکانی ڕاپۆرت و کۆگاکانی هەندێک جار بە ئەنقەست دووبارە هەڵدەگرن، بۆ ئەوەی پرسیارە گەورەکان کەمتریان پێویست بێت. ئەمە هەڵبژاردنێکی بەئاگایە کە دوای دەکرێت، نەک هۆکارێک بۆ وازهێنان لێی.
  • لە ناوەندەوە دەمێننەوە: هەموو هەنگاوێکی نوێ و نوێ دروست دەکات. ئەگەر دڵنیا نیت لە ، بگەڕێوە بۆ کلیلەکانی بنکەدراوە.
Quick checkپشکنینی خێراA large reporting system copies the department name into every row of a big sales table on purpose. What is this called?سیستەمێکی گەورەی ڕاپۆرت بە ئەنقەست ناوی بەش کۆپی دەکات بۆ هەموو خشتەیەکی گەورەی فرۆشتن. ئەمە پێی چی دەوترێت؟

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، course3Still 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گواستنەوەی نرخی دراو بۆ خشتەی bookPrices 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ڕاهێنانەکان

ExerciseڕاهێنانNormalize a bookshop's ordersداواکارییەکانی کتێبفرۆشێک نۆرماڵ بکە

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_name depends on order_no only through customer_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_price stays in order_line: it is the price of this sale, so it depends on the whole key. A 'current price' column, if wanted, would go into book.
  • (أ) 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.
ExerciseڕاهێنانA list of phone numbersلیستێکی ژمارەی مۆبایل

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 وەک . ئێستا قوتابییەک دەتوانێت هەر چەند ژمارەیەکی هەبێت.

ExerciseڕاهێنانFull, partial or transitive?تەواو، بەشەکی یان ناڕاستەوخۆ؟

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 off lecturer.) 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).
ExerciseڕاهێنانA construction company's hours reportڕاپۆرتی کاتژمێرەکانی کۆمپانیایەکی بیناسازی

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⁩یشدان؟

The monthly report (blank cells repeat the line above)ڕاپۆرتە مانگانەکە (خانە بەتاڵەکان هەمان دێڕی سەرەوەن)
proj_numproj_nameemp_numemp_namejob_classchg_hour_iqdhours
15Ankawa School101Aram KamalElectrical Engineer85,00023.8
103Shilan OmarElectrical Engineer85,00019.4
106Dilan HamaProgrammer35,00012.6
18Duhok Clinic101Aram KamalElectrical Engineer85,00017.0
105Karwan AzizDatabase Designer105,00035.7
114Hana RaufProgrammer35,00024.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_iqd depends on emp_num only through job_class, so split it off: job(job_class, chg_hour_iqd) and employee(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یشدان).
ExerciseڕاهێنانColleges, departments and majorsکۆلێژ، بەش و پسپۆڕی

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.

زانکۆیەک پسپۆڕییەکانی خۆی لە یەک هەڵدەگرێت. هەر پسپۆڕییەک سەر بە یەک بەشە و هەر بەشێکیش سەر بە یەک کۆلێژ. کام ڕاستییانە دووبارە دەبنەوە؟ بکە بە چەند و نێوانیان بنووسە.

collegedepartmentmajor
ScienceBiologyBiology
ScienceBiologyMicrobiology
ScienceComputer ScienceComputer Science
ScienceComputer ScienceInformation Systems
ScienceComputer ScienceNetworks
Administration and EconomicsEconomicsEconomics
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: هەموو .
  • لەسەر لەت بکە و بیکە بە کلیلی خشتە نوێیەکە: لەتکردنەکە بێ لەدەستدان دەبێت و بەجێ دەهێڵێت.
Review questionsپرسیارەکانی پێداچوونەوە
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.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.

Learn Database Normalization - 1NF, 2NF, 3NF, 4NF, 5NFDecomplexify · Englishئینگلیزی · 3.3M viewsبینین · 82K likesلایک · Partبەشی 0:00–20:29 (ofلە 28:34)

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زاراوە سەرەکییەکان

Next lessonوانەی داهاتوو

Relational Algebra and Relational Calculusجەبری پەیوەندیدار و ژمێرکاریی پەیوەندیدار

References and further readingسەرچاوەکان و خوێندنەوەی زیاتر

This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.