Chapterبەش 3 · Lectureوانە 3.3
Beyond the Basic E-R Model: Recursive, Ternary and Specialised Entitiesزیاتر لە مۆدێلی قەوارە و پەیوەندیی بنەڕەتی: پەیوەندییەکانی خۆیی و سێیانی و قەوارە تایبەتکراوەکان
The Enhanced E-R model for bigger designs: the degree of a relationship, recursive relationships with role names, relationship keys and attributes, ternary relationships and why three binaries are not the same, (min,max) limits, specialisation and generalisation with inheritance and constraints, categories, aggregation, and Chen, crow's-foot and UML notation side by side — with practice tasks and exam-style questions.
بۆ دیزاینی گەورەتر: ، لەگەڵ ، و ، و بۆچی سێ هەمان شت نین، سنووری (min,max)، و لەگەڵ و ڕێساکان، ، و و پێی قەلەڕەش و UML لە تەنیشت یەکتر — لەگەڵ ڕاهێنان و پرسیاری شێوەی تاقیکردنەوە.
What you will learnچی فێر دەبیت
- Name the degree of a relationship and draw recursive relationships with role names.
- Decide when a fact needs a ternary relationship, and find the key of any relationship.
- Read and write (min,max) constraints, stating which convention is used.
- Draw specialisation and generalisation hierarchies with disjoint/overlapping and total/partial constraints, categories and aggregation.
- Recognise the same constructs in Chen, crow's-foot and UML notation.
- دیاری بکەیت و لەگەڵ بکێشیت.
- بڕیار بدەیت کەی ڕاستییەک پێویستی بە هەیە و هەر بدۆزیتەوە.
- بخوێنیتەوە و بنووسیت و بڵێیت کام ڕێککەوتن بەکار هاتووە.
- پلەبەندیی و بە ڕێساکانی جیاکراوە/بەیەکداچوو و تەواو/بەشەکی، و بکێشیت.
- هەمان پێکهاتەکان لە ، و بناسیتەوە.
Why the basic model is not enoughبۆچی مۆدێلی قەوارە و پەیوەندیی بنەڕەتی بەس نییە؟
This lesson is the course's optional deeper step (level: advanced). You need it for design tasks such as the hospital exercise of the next lesson, From EER Diagrams to Tables. It builds on Entity-Relationship Modelling: entities, attributes and identifiers (the four building blocks), relationships, weak entities and total or partial participation. Read that lesson first: this one does not repeat it.
ئەم وانەیە هەنگاوێکی قووڵتر و هەڵبژاردەییە لە کۆرسەکەدا (ئاست: پێشکەوتوو). بۆ ئەرکی دیزاینی وەک ڕاهێنانی نەخۆشخانەی وانەی داهاتوو، لە هێڵکاریی EERـەوە بۆ خشتەکان، پێویستت پێیەتی. لەسەر وانەی مۆدێلی قەوارە و پەیوەندی بنیات نراوە: ، و ناسێنەرەکان (چوار بەردە بناغەکە)، پەیوەندییەکان، قەوارە لاوازەکان و بەشداریی تەواو یان بەشداریی بەشەکی. سەرەتا ئەو وانەیە بخوێنەوە: ئەم وانەیە دووبارەی ناکاتەوە.
With those blocks you can draw most databases. But three everyday situations are hard to say with them:
بەو بەردە بناغانە دەتوانیت زۆربەی بکێشیت. بەڵام سێ دۆخی ڕۆژانە بەوانە بە ئاسانی دەرنابڕدرێن:
- An employee who manages other employees. Both ends of the line are the same entity type, Staff. Which end is the manager?
- A doctor who prescribes a drug to a patient. One fact joins three things at once, not two.
- Staff who are either academic or administrative. They share a name and a salary, but each kind has attributes of its own.
- فەرمانبەرێک کە سەرپەرشتیی فەرمانبەرانی تر دەکات. هەردوو سەری هێڵەکە هەمان جۆری : «فەرمانبەر». کام سەر بەڕێوەبەرەکەیە؟
- دکتۆرێک کە دەرمانێک بۆ نەخۆشێک دەنووسێت. یەک ڕاستی سێ شت پێکەوە دەبەستێتەوە، نەک دوو.
- ستافێک کە یان مامۆستان یان کارمەندی کارگێڕی. ناو و مووچەیان هاوبەشە، بەڵام هەر جۆرێکیان تایبەت بە خۆی هەیە.
The with extra constructs for bigger designs: and ( and ), and . Entities, attributes and relationships stay as before.
لەگەڵ چەند بەشێکی زیادە بۆ دیزاینی گەورەتر: و ( و )، و . ، و وەک خۆیان دەمێننەوە.
The Enhanced E-R (EER) model adds what these cases need: role names and higher degrees, (min,max) limits, specialisation and generalisation, categories and aggregation. The next screens take them one by one; the next lesson turns them into tables.
ئەوەی ئەم دۆخانە پێویستیانە زیاد دەکات: و پلەی بەرزتر، سنووری (min,max)، و ، و . شاشەکانی داهاتوو یەک بە یەک باسیان دەکەن؛ وانەی داهاتوو دەیانکاتە .
Degree of a relationshipپلەی پەیوەندی
The number of entity types that take part in a : one (), two (), three () or more ().
ژمارەی جۆرەکانی کە لە بەشدارن: یەک ()، دوو ()، سێ () یان زیاتر ().
A relationship type is a set of combinations. Take the entity types E1, E2 … En. Every way of picking one entity from each is an element of their Cartesian product. The relationship keeps only the combinations that really happened, so it is a subset of that product:
کۆمەڵەیەک لێکدانە. جۆرەکانی E1، E2 … En وەربگرە. هەر ڕێگەیەک بۆ هەڵبژاردنی یەک لە هەر یەکێکیان ئەندامێکی لێکدانی دیکارتیی ئەوانە. تەنها ئەو لێکدانانە هەڵدەگرێت کە بە ڕاستی ڕوویان داوە، بۆیە بەشێکە لەو لێکدانە:
n is the degree: how many entity types take part.
n پلەکەیە: چەند جۆری بەشدارن.
Example: a clinic has 3 doctors, 40 patients and 25 drugs. The product holds possible triples, but this month only 120 prescriptions were written. The relationship prescribes holds those 120.
نموونە: نۆرینگەیەک 3 دکتۆر، 40 نەخۆش و 25 دەرمانی هەیە. لێکدانەکە سێیانەی گونجاو هەڵدەگرێت، بەڵام ئەم مانگە تەنها 120 ڕەچەتە نووسراون. «دەنووسێت» ئەو 120ـە هەڵدەگرێت.
| Degreeپلە | Nameناو | Exampleنموونە |
|---|---|---|
| 1 | unary (recursive) | Staff manages Staffفەرمانبەر سەرپەرشتیی فەرمانبەر دەکات |
| 2 | binary | Student takes Courseقوتابی وانە دەخوێنێت |
| 3 | ternary | Doctor prescribes Drug to Patientدکتۆر دەرمان بۆ نەخۆش دەنووسێت |
| n | n-ary | Lecturer teaches Course in Room at a Time slot (n = 4)مامۆستا وانە لە هۆڵێکدا لە کاتێکی دیاریکراودا دەڵێتەوە (n = 4) |
Recursive relationships and role namesپەیوەندییە خۆییەکان و ناوەکانی ڕۆڵ
A between entities of the SAME entity type, such as Staff manages Staff. on its two lines say which part each entity plays.
لە نێوان هەمان جۆردا، وەک «فەرمانبەر سەرپەرشتیی فەرمانبەر دەکات». لەسەر دوو هێڵەکەی دەڵێن هەر چ ڕۆڵێک دەگێڕێت.
In a company in Erbil, Hana manages Aram and Shilan, and Aram manages Karwan. All four are entities of the same type, STAFF. So the relationship manages has two lines that both go to STAFF. To read it, each line gets a role name: supervisor on one, subordinate on the other.
لە کۆمپانیایەک لە هەولێر، هانا سەرپەرشتیی ئارام و شیلان دەکات و ئارامیش سەرپەرشتیی کاروان دەکات. هەر چواریان هەمان جۆرن: «فەرمانبەر». بۆیە «سەرپەرشتی دەکات» دوو هێڵی هەیە کە هەردووکیان دەچنە سەر «فەرمانبەر». بۆ خوێندنەوەی، هەر هێڵێک وەردەگرێت: سەرپەرشتیار لەسەر یەکێکیان و ژێردەست لەسەر ئەوی تر.
Read it with the roles: one supervisor (1) manages many subordinates (N), and each subordinate has one supervisor. Hana has no supervisor, so that side is partial. Without role names nobody could tell which line means 'the boss'.
بە ڕۆڵەکانەوە بیخوێنەوە: یەک سەرپەرشتیار (1) سەرپەرشتیی چەندین ژێردەست (N) دەکات و هەر ژێردەستێک یەک سەرپەرشتیاری هەیە. هانا سەرپەرشتیاری نییە، بۆیە ئەو لایە بەشەکییە. بەبێ کەس نەیدەزانی کام هێڵ مانای «بەڕێوەبەر» دەدات.
A recursive relationship can store any directed graph: each entity is a node and each relationship row is an arrow, as in the right half of the picture. The state-space graphs of AI search are the same idea (State-space graph and search tree).
دەتوانێت هەر ئاراستەدار هەڵبگرێت: هەر و هەر تیرێکە، وەک نیوەی ڕاستی وێنەکە. گەڕانی هەمان بیرۆکەن (گرافی فەزای دۆخەکان).
Recursive relationships and role namesپەیوەندییە خۆییەکان و ناوەکانی ڕۆڵ
Prerequisites, parts and mothersپێشمەرج، پارچە و دایک
Recursive relationships are everywhere:
لە هەموو شوێنێکن:
- Course is a prerequisite of Course (M:N). DB201 needs DB101; Web Programming 2 needs Web Programming 1 and DB101; and DB101 opens the way to several courses. Roles: course and prerequisite.
- Part contains Part (M:N), a bill of materials. A bicycle contains two wheels, a wheel contains 32 spokes, and the same spoke is used in several wheel models. Roles: whole and component. The relationship can carry an attribute,
quantity. - Person is the mother of Person. Every person has exactly one mother, but not everyone is a mother, and a mother may have many children. With the (min,max) pairs of a later screen: (0,N) for the mother role and (1,1) for the child role.
- وانە پێشمەرجی وانەیە (
M:N). DB201 پێویستی بە DB101 هەیە؛ Web Programming 2 پێویستی بە Web Programming 1 و DB101 هەیە؛ DB101یش ڕێگە بۆ چەند وانەیەک دەکاتەوە. ڕۆڵەکان: وانە و پێشمەرج. - پارچە پارچە لەخۆ دەگرێت (
M:N)، لیستی پێکهاتەکان. پاسکیلێک دوو تایە لەخۆ دەگرێت، تایەیەک 32 تیلی هەیە و هەمان تیل لە چەند جۆرە تایەیەکدا بەکار دێت. ڕۆڵەکان: گشت و پێکهاتە. دەتوانێت هەڵبگرێت:quantity. - کەس دایکی کەسە. هەموو کەسێک ڕێک یەک دایکی هەیە، بەڵام هەموو کەسێک دایک نییە و دایکێک دەتوانێت چەندین منداڵی هەبێت. بە جووتەکانی (min,max)ی شاشەیەکی داهاتوو: (0,N) بۆ ڕۆڵی دایک و (1,1) بۆ ڕۆڵی منداڵ.
Recursive relationships and role namesپەیوەندییە خۆییەکان و ناوەکانی ڕۆڵ
Two relationships between the same entity typesدوو پەیوەندی لە نێوان هەمان جۆرەکانی قەوارە
The same two entity types can be joined by different relationships with different meanings. A person lives in one house, and a house has many residents (N:1). A person may also own several houses, and a house may have several owners (M:N). Draw two diamonds, each with its own cardinality; never squeeze two meanings into one line.
هەمان دوو جۆری دەکرێت بە چەند جیاواز و بە واتای جیاواز ببەسترێنەوە. کەسێک لە یەک خانوودا دەژی و خانوویەک چەندین دانیشتووی هەیە (N:1). هەمان کەس دەکرێت خاوەنی چەند خانوویەک بێت و خانوویەکیش چەند خاوەنێکی هەبێت (M:N). دوو ئەڵماسی بکێشە، هەر یەکەیان بە خۆی؛ هەرگیز دوو واتا مەخەرە ناو یەک هێڵ.
The delivery exercise of the next lesson has the same pattern: a package is sent by one customer and received by one customer. The role names sender and receiver keep the two apart.
ڕاهێنانی گەیاندنی وانەی داهاتوو هەمان شێوەی هەیە: پاکەتێک لەلایەن یەک کڕیارەوە دەنێردرێت و یەک کڕیار وەریدەگرێت. نێرەر و وەرگر لێکیان جیا دەکەنەوە.
The key of a relationshipکلیلی پەیوەندییەک
Every row of a relationship must be told apart from the others, like an entity row. The identifier (key) of a relationship is the smallest set of the participating entities' keys that does this. The cardinality decides which keys you need:
هەر دەبێت لە ئەوانی تر جیا بکرێتەوە، وەک . ناسێنەری () کەمترین ژمارەی بەشداربووانە کە ئەم کارە دەکەن. بڕیار دەدات کام پێویستە:
| Relationship | Cardinality | Its key |
|---|---|---|
| Student takes Courseقوتابی وانە دەخوێنێت | M:N | {student_id, course_code}: a student takes many courses and a course has many students, so neither key alone is enough.{student_id, course_code}: قوتابییەک چەندین وانە دەخوێنێت و وانەیەک چەندین قوتابیی هەیە، بۆیە هیچ بە تەنها بەس نییە. |
| Lecturer belongs to Departmentمامۆستا سەر بە بەشە | N:1 | {staff_no}: each lecturer belongs to one department, so the lecturer's key alone identifies the row.{staff_no}: هەر مامۆستایەک سەر بە یەک بەشە، بۆیە مامۆستا بە تەنها دەناسێنێت. |
| Dean manages Collegeڕاگر کۆلێژ بەڕێوە دەبات | 1:1 | {dean_id} or {college_id}: either key works.{dean_id} یان {college_id}: هەر کامیان بێت کار دەکات. |
The key of a relationshipکلیلی پەیوەندییەک
Attributes of a relationshipخەسڵەتەکانی پەیوەندییەک
A relationship can also have attributes of its own (descriptive attributes): facts about the link, not about either entity. A grade belongs to takes (Aram's grade in DB101), a price to sells (one drug's price at one pharmacy), hours to works on. Each is an oval joined to the diamond, and later a column of the relationship's table, as in M:N needs a third table.
دەشتوانێت تایبەت بە خۆی هەبێت: ڕاستی دەربارەی بەستنەوەکە، نەک دەربارەی یەکێک لە . نمرە سەر بە «دەخوێنێت»ـە (نمرەی ئارام لە DB101)، نرخ سەر بە «دەفرۆشێت»ـە (نرخی دەرمانێک لە یەک دەرمانخانە)، کاتژمێرەکان سەر بە «کار دەکات لەسەر»ـن. هەر یەکەیان هێلکەییەکە کە بە ئەڵماسییەکەوە بەستراوە و دواتر ، وەک لە M:N پێویستی بە خشتەیەکی سێیەم هەیە.
Ternary relationshipsپەیوەندییە سێیانییەکان
A among three entity types whose rows are triples, such as a doctor prescribing a drug to a patient. It keeps facts that three separate binary relationships cannot.
لە نێوان سێ جۆری کە هەر سێیانەیەکە، وەک دکتۆرێک کە دەرمانێک بۆ نەخۆشێک دەنووسێت. ئەو ڕاستییانە دەپارێزێت کە سێ جیا ناتوانن بیانپارێزن.
Some facts need three entities at once. Supplier–Part–Project: Aram Trading supplies bolts to the Erbil bridge project. A hospital prescription: Dr Hana prescribed Feverol to Aram, with a date and a quantity that belong to the whole triple. One diamond joins the three entity types.
هەندێک ڕاستی پێویستیان بە سێ پێکەوە هەیە. دابینکەر–پارچە–پڕۆژە: Aram Trading بورغی بۆ پڕۆژەی پردەکەی هەولێر دابین دەکات. ڕەچەتەی نەخۆشخانە: دکتۆر هانا Feverolـی بۆ ئارام نووسی، لەگەڵ بەروار و بڕێک کە سەر بە هەموو سێیانەکەن. یەک ئەڵماسی هەر سێ جۆرەکەی پێکەوە دەبەستێتەوە.
Each row of a ternary relationship is a triple plus its attributes. In the supplier example the attribute is qty: how many bolts went from that supplier to that project. With no 1 on any line (M:N:P), the key of the relationship is all three keys together.
هەر سێیانەیەکە لەگەڵ . لە نموونەی دابینکەردا qtyـە: چەند بورغی لەو دابینکەرەوە بۆ ئەو پڕۆژەیە چووە. کاتێک لەسەر هیچ هێڵێک 1 نییە (M:N:P)، هەر سێ پێکەوە.
Ternary relationshipsپەیوەندییە سێیانییەکان
Why three binaries lose informationبۆچی سێ پەیوەندیی دووانی زانیاری ون دەکەن
It is tempting to replace a ternary with three binaries: supplier–part, part–project and supplier–project. Here are three true facts and the pairs they give:
وا دەردەکەوێت کە دەکرێت بە سێ بگۆڕدرێت: دابینکەر–پارچە، پارچە–پڕۆژە و دابینکەر–پڕۆژە. ئەمە سێ ڕاستیی ڕاستە و ئەو جووتانەی لێیان دەردەچن:
| supplies (supplier, part, project)supplies (دابینکەر، پارچە، پڕۆژە) | supplier–partدابینکەر–پارچە | part–projectپارچە–پڕۆژە | supplier–projectدابینکەر–پڕۆژە |
|---|---|---|---|
| Aram Trading, bolts, Bridge | Aram Trading, bolts | bolts, Bridge | Aram Trading, Bridge |
| Aram Trading, cables, School | Aram Trading, cables | cables, School | Aram Trading, School |
| Dilan Trading, bolts, School | Dilan Trading, bolts | bolts, School | Dilan Trading, School |
Now ask: who supplies bolts to the School? The ternary answers Dilan Trading. The pairs cannot: Aram Trading supplies bolts, bolts go to the School, and Aram Trading works for the School. Joining the pairs back produces a fourth, false triple:
ئێستا بپرسە: کێ بورغی بۆ قوتابخانەکە دابین دەکات؟ وەڵام دەداتەوە: Dilan Trading. جووتەکان ناتوانن: Aram Trading بورغی دابین دەکات، بورغی دەچێتە قوتابخانەکە و Aram Trading بۆ قوتابخانەکە کار دەکات. جووتەکان سێیانەیەکی چوارەمی هەڵە دروست دەکات:
SELECT sp.supplier, sp.part, pj.project
FROM supplier_part AS sp
JOIN part_project AS pj ON pj.part = sp.part
JOIN supplier_project AS sj
ON sj.supplier = sp.supplier AND sj.project = pj.project;supplier | part | project Aram Trading | bolts | Bridge Aram Trading | bolts | School Aram Trading | cables | School Dilan Trading | bolts | School
Four rows for three facts: (Aram Trading, bolts, School) never happened.
چوار بۆ سێ ڕاستی: (Aram Trading, bolts, School) هەرگیز ڕووی نەداوە.
Ternary relationshipsپەیوەندییە سێیانییەکان
A 1 on one side of a ternaryژمارە 1 لە یەک لای پەیوەندییەکی سێیانی
A 1 at one entity of a ternary is a rule about the other two together. In Supplier–Part–Project, a 1 at Supplier means: each (part, project) pair has exactly one supplier. The pair decides the supplier, so the key of the relationship shrinks to (part, project).
1 لە لای یەک لە یاسایەکە دەربارەی دووەکەی تر پێکەوە. لە دابینکەر–پارچە–پڕۆژەدا، 1 لە لای دابینکەر واتە: هەر جووتێکی (پارچە، پڕۆژە) ڕێک یەک دابینکەری هەیە. جووتەکە دابینکەرەکە دیاری دەکات، بۆیە کورت دەبێتەوە بۆ (پارچە، پڕۆژە).
Exams like this pattern. In a college's labs, each student uses exactly one computer for each course: Aram uses PC-07 for DB101 and PC-12 for NET101. That is a ternary Student–Course–Computer with 1 at Computer: each (student, course) pair has one computer. Binaries could not say 'one computer per course'.
تاقیکردنەوەکان ئەم شێوەیەیان خۆش دەوێت. لە تاقیگەکانی کۆلێژێکدا هەر قوتابییەک بۆ هەر وانەیەک ڕێک یەک بەکار دەهێنێت: ئارام بۆ وانەی DB101 PC-07 و بۆ وانەی NET101 PC-12 بەکار دەهێنێت. ئەمە قوتابی–وانە– بە 1 لە لای : هەر جووتێکی (قوتابی، وانە) یەک هەیە. نەیاندەتوانی بڵێن «یەک بۆ هەر وانەیەک».
(min,max): at least and at most(min,max): لانیکەم و لانیزۆر
A pair of numbers on the line between an entity type and a : at least how many and at most how many relationships each entity takes part in. Min 0 means , min 1 or more means .
جووتێک ژمارە لەسەر هێڵی نێوان جۆرێکی و : هەر لانیکەم و لانیزۆر لە چەند بەشدار دەبێت. کەمترین 0 واتە ؛ کەمترین 1 یان زیاتر واتە .
1 and N say only one or many, and a double line says at least one. Real rules are often sharper: a student takes at least 2 and at most 8 courses; a course runs only with at least 4 students. A (min,max) pair on each line says exactly that: Student (2,8) — takes — (4,N) Course.
1 و N تەنها دەڵێن یەک یان زۆر و هێڵی دووانەش دەڵێت لانیکەم یەک. یاسا ڕاستەقینەکان زۆرجار وردترن: قوتابییەک لانیکەم 2 و لانیزۆر 8 وانە دەخوێنێت؛ وانەیەک تەنها بە لانیکەم 4 قوتابی دەکرێتەوە. جووتێکی (min,max) لەسەر هەر هێڵێک ڕێک ئەمە دەڵێت: قوتابی (2,8) — دەخوێنێت — (4,N) وانە.
- (2,8) next to Student: each student takes 2 to 8 courses.
- (4,N) next to Course: each course has 4 or more students; N means no upper limit.
- (2,8) لە تەنیشت «قوتابی»: هەر قوتابییەک 2 تا 8 وانە دەخوێنێت.
- (4,N) لە تەنیشت «وانە»: هەر وانەیەک 4 قوتابی یان زیاتری هەیە؛ N واتە سنووری سەرەوە نییە.
A (min,max) pair also contains the older marks: min 0 = partial participation, min 1 or more = total participation (the double line), max 1 = 'one', max N = 'many'.
جووتێکی (min,max) نیشانە کۆنەکانیش لەخۆ دەگرێت: کەمترین 0 = ، کەمترین 1 یان زیاتر = (هێڵی دووانە)، زۆرترین 1 = «یەک»، زۆرترین N = «زۆر».
| Pairجووت | Each entity takes part …هەر بەشدار دەبێت … | Old marksنیشانە کۆنەکان |
|---|---|---|
| (0,1) | at most once, maybe neverلانیزۆر یەکجار، لەوانەیە هەرگیز | single line, 1هێڵی تاک، 1 |
| (1,1) | exactly onceڕێک یەکجار | double line, 1هێڵی دووانە، 1 |
| (0,N) | any number of timesهەر ژمارەیەک جار | single line, Nهێڵی تاک، N |
| (1,N) | at least onceلانیکەم یەکجار | double line, Nهێڵی دووانە، N |
| (2,8) | 2 to 8 times2 تا 8 جار | double line, N: the 2 and the 8 are lostهێڵی دووانە، N: ژمارە 2 و 8 ون دەبن |
(min,max): at least and at most(min,max): لانیکەم و لانیزۆر
Which side? Read the conventionکام لا؟ ڕێککەوتنەکە بخوێنەوە
This course's convention: a (min,max) pair stands next to the entity it describes and counts how many relationships EACH entity of that type takes part in (the textbooks Fundamentals of Database Systems and Database System Concepts do this; the second writes the pair as l..h). The 1/N marks of E-R modelling are read across the line. So the same fact sits on opposite sides:
ڕێککەوتنی ئەم کۆرسە: جووتێکی (min,max) لە تەنیشت ئەو دادەنرێت کە وەسفی دەکات و دەژمێرێت هەر ئەو جۆرە لە چەند بەشدارە (کتێبەکانی Fundamentals of Database Systems و Database System Concepts بەم شێوەیە دەیکەن؛ دووەمیان جووتەکە وەک l..h دەنووسێت). نیشانەکانی 1/Nـی مۆدێلی قەوارە و پەیوەندی بە سەر هێڵەکەدا دەخوێنرێنەوە. بۆیە هەمان ڕاستی لە دوو لای پێچەوانەدایە:
(min,max): at least and at most(min,max): لانیکەم و لانیزۆر
Two slips in the course slidesدوو هەڵە لە سلایدەکانی کۆرسەکەدا
Specialisation and generalisationتایبەتکردن و گشتاندن
Top-down design: splitting an entity type into that have their own attributes or relationships, such as Account into savings, current and fixed-deposit accounts. Each subclass entity IS A superclass entity.
دیزاینی سەرەوە بۆ خوارەوە: دابەشکردنی جۆرێکی بۆ چەند کە یان تایبەت بە خۆیان هەیە، وەک دابەشکردنی «هەژمار» بۆ هەژماری پاشەکەوت، ڕۆژانە و دانراوی ماوەدار. هەر جۆرێکە لە .
A bank in Sulaymaniyah keeps three kinds of account. All of them have an account number, a holder and a balance in IQD. A savings account also has an interest rate; a current account has an overdraft limit; a fixed deposit has a start date and a maturity date. As one entity type, most of these attributes would stay empty for most accounts.
بانکێک لە سلێمانی سێ جۆر هەژمار ڕادەگرێت. هەموویان ژمارەی هەژمار، خاوەن و باڵانسیان بە دینار هەیە. هەژماری پاشەکەوت ڕێژەی سوودیشی هەیە؛ هەژماری ڕۆژانە (current account، کە بانکەکان بە «حسابی جاری» ناوی دەبەن) سنووری کێشانەوەی زیادەی (overdraft) هەیە؛ دانراوی ماوەدار ڕێکەوتی دەستپێک و ڕێکەوتی تەواوبوونی هەیە. ئەگەر هەموویان یەک جۆری بن، زۆربەی ئەم بۆ زۆربەی هەژمارەکان بەتاڵ دەمێننەوە.
Specialisation (top-down) starts from ACCOUNT, the superclass, and defines the subclasses SAVINGS, CURRENT and FIXED DEPOSIT. Generalisation (bottom-up) goes the other way: you notice that three entity types share attributes and build the superclass above them. Both end in the same diagram; the animation shows both directions.
(لە سەرەوە بۆ خوارەوە) لە «هەژمار»ـەوە دەست پێدەکات، کە و «پاشەکەوت»، «ڕۆژانە» و «دانراوی ماوەدار» دیاری دەکات. (لە خوارەوە بۆ سەرەوە) پێچەوانەکەیە: تێبینی دەکەیت سێ جۆری هاوبەشیان هەیە و لە سەرووی ئەوانەوە دروست دەکەیت. هەردووکیان بە هەمان هێڵکاری کۆتایی دێن؛ وێنە جووڵاوەکە هەردوو ئاراستە پیشان دەدات.


The link between a subclass and its superclass is IS-A: a savings account is an account. One savings-account entity is the very same thing as one account entity, so this link is 1:1, never 1:N.
بەستنەوەی نێوان و IS-Aـە: هەژماری پاشەکەوت جۆرێکە لە هەژمار. هەژماری پاشەکەوت ڕێک هەمان شتە وەک هەژمار، بۆیە ئەم بەستنەوەیە 1:1ـە، هەرگیز 1:N نا.
Generalisation (bottom-up) and specialisation (top-down) on a whiteboard, with Person/Student/Teacher and Account/savings/current examples.
(لە خوارەوە بۆ سەرەوە) و (لە سەرەوە بۆ خوارەوە) لەسەر تەختە، بە نموونەی Person/Student/Teacher و Account/savings/current.
Plays 0:45-6:38: generalisation (Person with Student and Teacher), then specialisation (Account into savings and current), drawn with an ISA triangle; the lesson uses a circle with d - same idea.
لە 0:45 تا 6:38 پەخش دەبێت: (Person لەگەڵ Student و Teacher)، پاشان (Account بۆ savings و current) بە سێگۆشەی ISA دەیانکێشێت؛ ئەم وانەیە بازنەیەک بە d بەکاردەهێنێت، بەڵام بیرۆکەکە هەمان شتە.
Specialisation and generalisationتایبەتکردن و گشتاندن
Inheritance: what a subclass gets for freeبۆماوەی خەسڵەت: ئەوەی ژێرپۆلێک بەخۆڕایی وەریدەگرێت
In a , every automatically has all the attributes and relationships of its ; only its own extra ones are drawn on it.
لە ، هەر بە شێوەیەکی خۆکار هەموو و هەیە؛ تەنها ئەوانەی تایبەت بە خۆین لەسەری دەکێشرێن.
A savings account has its own interest_rate and everything ACCOUNT has: acct_no, holder and balance_iqd. It also inherits ACCOUNT's relationships: if every account is held at a branch, so is every savings account. So you draw only the extra attributes on a subclass.
هەژماری پاشەکەوت interest_rateـی خۆی هەیە و هەموو ئەوەی «هەژمار» هەیەتی: acct_no، holder و balance_iqd. «هەژمار»یش بە میرات وەردەگرێت: ئەگەر هەموو هەژمارێک لە لقێکدا بێت، هەموو هەژمارێکی پاشەکەوتیش لە لقێکدایە. بۆیە لەسەر تەنها دەکێشیت.
Inheritance goes down every level. In the staff example of the next screen, an academic inherits from STAFF, which inherits from PERSON: an academic has person_id, name, date_of_birth, salary_iqd and rank. Generalisation stresses what the kinds have in common; specialisation stresses what makes each kind special.
بە هەموو ئاستەکاندا دادەبەزێت. لە نموونەی ستافی شاشەی داهاتوودا، مامۆستایەک لە «فەرمانبەر»ـەوە میرات وەردەگرێت و ئەویش لە «کەس»ـەوە: مامۆستایەک person_id، name، date_of_birth، salary_iqd و rankـی هەیە. جەخت لەسەر ئەوە دەکاتەوە کە جۆرەکان هاوبەشیانە؛ جەخت لەسەر ئەوە دەکاتەوە کە هەر جۆرێک تایبەت دەکات.
Specialisation and generalisationتایبەتکردن و گشتاندن
Disjoint or overlapping, total or partialجیاکراوە یان بەیەکداچوو، تەواو یان بەشەکی
Two questions decide how a specialisation is drawn:
دوو پرسیار بڕیار دەدەن چۆن دەکێشرێت:
- Can one entity be in two subclasses? No → disjoint, a d in the circle (an account is savings or current, never both). Yes → overlapping, an o (a person can be staff and a student of the same university).
- Must every superclass entity be in some subclass? Yes → total, a double line from the superclass to the circle (every staff member is academic or administrative). No → partial, a single line (a visitor is a person but neither staff nor student).
- دەکرێت یەک لە دوو بێت؟ نەخێر ← جیاکراوە، پیتی d لە ناو بازنەکەدا (هەژمارێک یان پاشەکەوتە یان ڕۆژانە، هەرگیز هەردووکیان نا). بەڵێ ← بەیەکداچوو، پیتی o (کەسێک دەتوانێت هەم فەرمانبەر بێت هەم قوتابیی هەمان زانکۆ).
- دەبێت هەموو لە بێت؟ بەڵێ ← تەواو، هێڵی دووانە لە بۆ بازنەکە (هەموو فەرمانبەرێک یان مامۆستایە یان کارگێڕی). نەخێر ← بەشەکی، هێڵی تاک (میوانێک کەسە بەڵام نە فەرمانبەرە نە قوتابی).
Specialisation and generalisationتایبەتکردن و گشتاندن
Constraints: examples and a slipڕێساکان: نموونە و هەڵەیەک
A typical case: every employee of a bank branch is a teller, a loan officer or a manager, one job each. That is disjoint (one job) and total (everyone has one). A superclass built by generalisation is usually total: STAFF made from academic and administrative staff contains exactly their union.
نموونەیەکی باو: هەر فەرمانبەرێکی لقی بانکێک یان کاشێرە، یان فەرمانبەری قەرزە، یان بەڕێوەبەرە؛ بۆ هەر کەسێک یەک پیشە. ئەمە جیاکراوەیە (یەک پیشە) و تەواوە (هەمووان یەکێکیان هەیە). کە بە دروست کرابێت زۆرجار تەواوە: «ستاف» کە لە مامۆستایان و کارمەندانی کارگێڕی دروست کراوە ڕێک ئەوان لەخۆ دەگرێت.
Specialisation and generalisationتایبەتکردن و گشتاندن
Specialising by a valueتایبەتکردن بەپێی نرخێک
Sometimes one attribute decides the subclass. In Kurdistan's universities an academic's title is assistant lecturer, lecturer, assistant professor or professor. Specialising ACADEMIC by the value of title gives four subclasses (some books call this a decomposition by rank). title is the defining attribute; write it next to the circle.
هەندێک جار یەک دیاری دەکات. لە زانکۆکانی کوردستان نازناوی مامۆستایەک مامۆستای یاریدەدەر، مامۆستا، پرۆفیسۆری یاریدەدەر یان پرۆفیسۆرە. «مامۆستا» بەپێی نرخی title چوار دەدات (هەندێک کتێب پێی دەڵێن دابەشکردن بەپێی پلە). title دیاریکەرە؛ لە تەنیشت بازنەکەوە بینووسە.
Such a specialisation is disjoint by nature (one title at a time) and total if every academic has a title. It is worth drawing only when the subclasses differ: for example, only professors may supervise PhD students.
ئەم جۆرە بە سروشتی جیاکراوەیە (لە یەک کاتدا یەک نازناو) و تەواوە ئەگەر هەموو مامۆستایەک نازناوێکی هەبێت. تەنها کاتێک شایەنی کێشانە کە جیاواز بن: بۆ نموونە، تەنها پرۆفیسۆرەکان دەتوانن سەرپەرشتیی قوتابیانی دکتۆرا بکەن.
Specialisation and generalisationتایبەتکردن و گشتاندن
Categories (union types)جۆرەکانی یەکگرتن
An entity type whose members each come from ONE of several different , drawn with ∪ in the circle: an Owner is a Person or a Company. Its table usually needs a .
جۆرێکی کە هەر ئەندامێکی لە یەکێک لە چەند جیاوازەوە دێت و بە ∪ لە ناو بازنەکەدا دەکێشرێت: «خاوەن» یان کەسە یان کۆمپانیا. زۆرجار پێویستی بە هەیە.
Specialisation splits ONE superclass. A category works the other way: its members come from DIFFERENT superclasses. The owner of a registered vehicle in Erbil can be a person (with a national ID) or a company (with a registration number). OWNER is the union of the two, drawn with a U sign in the circle; each owner is exactly one of them. The line from the circle to OWNER is single: not every person or company owns a vehicle, so the category is partial (a double line would make all of them owners).
یەک دابەش دەکات. بە پێچەوانەوە کار دەکات: ئەندامەکانی لە چەند جیاوازەوە دێن. خاوەنی ئۆتۆمبێلێکی تۆمارکراو لە هەولێر دەکرێت کەسێک بێت (بە ژمارەی ناسنامەی نیشتمانی) یان کۆمپانیایەک (بە ژمارەی تۆمار). «خاوەن» ئەو دووانەیە و بە نیشانەی U لە ناو بازنەکەدا دەکێشرێت؛ هەر خاوەنێک ڕێک یەکێکیانە. هێڵی نێوان بازنەکە و «خاوەن» تاکە: هەموو کەس و کۆمپانیایەک خاوەنی ئۆتۆمبێل نییە، بۆیە بەشەکییە (هێڵی دووانە هەموویانی دەکردە خاوەن).
PERSON and COMPANY have different keys, so OWNER gets a new key of its own, owner_id (a surrogate key); the table version shows it. Some books also show the opposite case, intersection: a lecturer with a joint appointment in two faculties belongs to both, a shared subclass of the two.
«کەس» و «کۆمپانیا» جیاوازیان هەیە، بۆیە «خاوەن» نوێی خۆی وەردەگرێت: owner_id (کلیلی دەستکرد)؛ وەشانی خشتە پیشانی دەدات. هەندێک کتێب حاڵەتی پێچەوانەش پیشان دەدەن، : مامۆستایەک کە بە دامەزراندنی هاوبەش لە دوو کۆلێژدا کار دەکات سەر بە هەردووکیانە، هاوبەشی ئەو دووانە.
Aggregation: a relationship inside a boxگردکردنەوە: پەیوەندییەک لە ناو سندوقێکدا
Treating a together with its entities as one higher-level entity, so that it can take part in another relationship; drawn as a box around them. An employee working on a project uses a machine.
مامەڵەکردن لەگەڵ و وەک یەک ئاستبەرز، بۆ ئەوەی بتوانێت لە تردا بەشدار بێت؛ وەک سندوقێک بە دەوریاندا دەکێشرێت. فەرمانبەرێک کە لەسەر پڕۆژەیەک کار دەکات ئامێرێک بەکار دەهێنێت.
Employees work on projects (M:N), and while working on a project an employee uses machines. Try two relationships: EMPLOYEE works on PROJECT, and EMPLOYEE uses MACHINE. The second one loses the project: Aram uses the crane, but on which project? The basic E-R model cannot join one relationship to another.
فەرمانبەران لەسەر پڕۆژەکان کار دەکەن (M:N) و لە کاتی کارکردن لەسەر پڕۆژەیەکدا فەرمانبەرێک ئامێر بەکار دەهێنێت. دوو تاقی بکەرەوە: «فەرمانبەر لەسەر پڕۆژە کار دەکات» و «فەرمانبەر ئامێر بەکار دەهێنێت». دووەمیان پڕۆژەکە ون دەکات: ئارام کرێن بەکار دەهێنێت، بەڵام لەسەر کام پڕۆژە؟ بنەڕەتی ناتوانێت بە ترەوە ببەستێتەوە.
Aggregation solves it: draw a box around works on and its two entities, and treat the box as one higher-level entity. Then uses joins the box to MACHINE: each work assignment (employee, project) uses some machines.
چارەسەری دەکات: سندوقێک بە دەوری «کار دەکات لەسەر» و دوو بکێشە و سندوقەکە وەک ئاستبەرز ببینە. ئینجا «بەکار دەهێنێت» سندوقەکە بە «ئامێر»ـەوە دەبەستێتەوە: هەر کارێکی دیاریکراو (فەرمانبەر، پڕۆژە) هەندێک ئامێر بەکار دەهێنێت.


Now the rule is part of the diagram: a machine is used only within an existing work assignment. The line from uses touches the box, not the inner diamond. A ternary Employee–Project–Machine alone would not say this: it would allow a machine use for a project the employee does not work on, and a work assignment without machines would have no place.
ئێستا یاساکە بەشێکە لە هێڵکارییەکە: ئامێر تەنها لە ناو کارێکی دیاریکراوی هەبوودا بەکار دەهێنرێت. هێڵی «بەکار دەهێنێت» بەر سندوقەکە دەکەوێت، نەک بەر ئەڵماسییەکەی ناوەوە. فەرمانبەر–پڕۆژە–ئامێر بە تەنها ئەمە ناڵێت: ڕێگە دەدات ئامێرێک بۆ پڕۆژەیەک بەکار بهێنرێت کە فەرمانبەرەکە لەسەری کار ناکات و کارێکی بێ ئامێریش شوێنی نابێت.
Aggregation: a relationship inside a boxگردکردنەوە: پەیوەندییەک لە ناو سندوقێکدا
Two more aggregationsدوو گردکردنەوەی تر
Only a member may chair a department. Lecturers are members of departments (M:N), and each department has one chair. A chairs relationship straight from LECTURER to DEPARTMENT would allow a chair from outside. Put a box around member of and draw chairs from DEPARTMENT to the box, with (1,1) at the department and (0,1) at the membership. Now every chair is one of the department's memberships; the table version shows the database refusing an outsider.
تەنها ئەندامێک دەتوانێت سەرۆکی بەشێک بێت. مامۆستایان ئەندامی بەشەکانن (M:N) و هەر بەشێک یەک سەرۆکی هەیە. «سەرۆکایەتی دەکات» ڕاستەوخۆ لە «مامۆستا»وە بۆ «بەش» ڕێگە بە سەرۆکێکی دەرەوە دەدات. سندوقێک بە دەوری «ئەندامە لە»دا بکێشە و «سەرۆکایەتی دەکات» لە «بەش»ـەوە بۆ سندوقەکە بکێشە، بە (1,1) لە لای بەش و (0,1) لە لای ئەندامێتی. ئێستا هەموو سەرۆکێک یەکێکە لە ئەندامێتییەکانی بەشەکە؛ وەشانی خشتە پیشان دەدات کەسێکی دەرەوە ڕەت دەکاتەوە.
A gerund often means aggregation. A gerund is a verb used as a noun: the shipping, the teaching. 'Products are shipped to customers, and the shipping is done by a delivery driver.' The shipping is the relationship ships to (PRODUCT–CUSTOMER) treated as a thing; done by joins that box to DRIVER.
چاوگ زۆرجار مانای دەدات. چاوگ کارێکە کە وەک ناو بەکار دێت: گەیاندن، وانەوتنەوە. «کاڵاکان بۆ کڕیاران دەنێردرێن و گەیاندنەکە لەلایەن شۆفێرێکی گەیاندنەوە ئەنجام دەدرێت.» گەیاندنەکە «دەنێردرێت بۆ»یە (کاڵا–کڕیار) کە وەک شتێک مامەڵەی لەگەڵ دەکرێت؛ «ئەنجام دەدرێت لەلایەن» ئەو سندوقە بە «شۆفێر»ـەوە دەبەستێتەوە.
Three ways of drawing, one pageسێ شێوازی کێشان لە یەک لاپەڕەدا
This course draws in Chen notation (all its symbols). Design tools and other books use crow's foot or UML class diagrams. The table shows the same constructs in all three.
ئەم کۆرسە بە دەکێشێت (هەموو هێماکانی). ئامرازەکانی دیزاین و کتێبەکانی تر یان بەکار دەهێنن. خشتەی خوارەوە هەمان پێکهاتەکان بە هەر سێکیان پیشان دەدات.
- Crow's foot puts the attributes inside the box and shows two marks at each end of a line: the mark next to the box is the maximum (bar = 1, crow's foot = many), the other one the minimum (ring = 0, bar = 1). Two bars mean exactly one (mandatory); a ring means optional.
- Crow's foot has no diamond: a relationship with attributes or with three entities becomes a middle entity.
- UML writes multiplicities such as
0..*and1..1, read across the line like Chen's 1/N. A relationship's attributes go into an association class joined by a dashed line.
- دەخاتە ناو سندوقەکەوە و لە هەر سەرێکی هێڵ دوو نیشانە پیشان دەدات: ئەوەی بە سندوقەکەوە نزیکە زۆرترینە (هێڵ = 1، پێی قەلەڕەش = زۆر)، ئەوی تر کەمترینە (بازنە = 0، هێڵ = 1). دوو هێڵ واتە ڕێک یەک (ناچاری)؛ بازنە واتە ئارەزوومەندانە.
- ئەڵماسیی نییە، بۆیە کە هەبێت، یان سێ هەبێت، دەبێتە ناوەند.
- UML ژمارەی وەک
0..*و1..1دەنووسێت کە وەک 1/Nـی Chen بە سەر هێڵدا دەخوێنرێنەوە. دەچنە ناو پەیوەندی کە بە هێڵێکی پچڕپچڕ بەستراوە.
Three ways of drawing, one pageسێ شێوازی کێشان لە یەک لاپەڕەدا
Multi-valued, ISA and recursive in three notationsخەسڵەتی فرەنرخ، ISA و پەیوەندیی خۆیی بە سێ شێواز
Older books use still other marks: a multi-valued attribute written with a star or in braces, a weak entity's identifier dependency shown with an arrow or a bar, total participation written as a minimum of 1 (1..1, 1..*), and a derived attribute as a dotted oval with a dotted line.
کتێبە کۆنەکان نیشانەی تریش بەکار دەهێنن: بە ئەستێرەیەک یان لە ناو کەوانەی {}دا، وابەستەیی ناساندنی بە تیرێک یان هێڵێک، وەک کەمترین 1 (1..1، 1..*) و وەک هێلکەیی و هێڵی خاڵخاڵ.
Common mistakesهەڵە باوەکان
| Mistakeهەڵە | What is rightڕاستییەکە |
|---|---|
| Drawing a ternary fact as three binary relationships.کێشانی ڕاستییەکی سێیانی وەک سێ . | The pairs cannot rebuild the triples; joining them adds false rows. Use one ternary diamond.جووتەکان ناتوانن سێیانەکان دروست بکەنەوە؛ هەڵە زیاد دەکات. یەک ئەڵماسیی سێیانی بەکار بهێنە. |
| Labelling ISA lines '1:n'.نیشانکردنی هێڵەکانی ISA بە «1:n». | ISA is not a cardinality: one subclass entity is one superclass entity. Use d/o and single/double lines.ISA نییە: . d/o و هێڵی تاک/دووانە بەکار بهێنە. |
| Reading a (min,max) pair as if it were 1/N.خوێندنەوەی جووتێکی (min,max) وەک 1/N. | In this course the pair stands next to the entity it describes; 1/N is read across the line. Always say which convention a diagram uses.لەم کۆرسەدا جووتەکە لە تەنیشت ئەو کە وەسفی دەکات؛ 1/N بە سەر هێڵدا دەخوێنرێتەوە. هەمیشە بڵێ هێڵکارییەک کام ڕێککەوتن بەکار دەهێنێت. |
| Drawing foreign keys, or arrows between keys, in an E-R diagram.کێشانی ، یان تیر لە نێوان ، لە . | An E-R diagram has entities and relationships; foreign keys appear only in the tables. و تێدایە؛ تەنها لە دەردەکەون. |
| Calling 'the degrees a person holds' a composite attribute.ناونانی «ئەو بڕوانامانەی کەسێک هەیەتی» بە . | Several values of one kind make it multi-valued (double oval). Composite means one value made of parts, like a name.چەند نرخێکی یەک جۆر دەیکاتە فرەنرخ (هێلکەیی دووانە). لێکدراو واتە یەک نرخ کە لە چەند بەشێک پێکهاتووە، وەک ناو. |
Saying a weak entity is always 1:1 with its owner.گوتنی ئەوەی هەمیشە لەگەڵ خاوەنەکەیدا 1:1ـە. | An owner usually has many weak entities: a patient has many visits (1:N).خاوەنێک زۆرجار چەندین هەیە: نەخۆشێک چەندین سەردانی هەیە (1:N). |
| A recursive relationship with no role names. بەبێ . | Name both lines (supervisor/subordinate); the names later become column names.هەردوو هێڵەکە ناو بنێ (سەرپەرشتیار/ژێردەست)؛ ناوەکان دواتر دەبنە ناوی . |
| Joining the outer relationship of an aggregation to the inner diamond.بەستنەوەی دەرەوەی بە ئەڵماسییەکەی ناوەوە. | Its line touches the box: it relates to the whole (entity, relationship, entity) unit.هێڵەکەی بەر سندوقەکە دەکەوێت: پەیوەندیی بە هەموو یەکەی (، ، )ەوە هەیە. |
Practiceڕاهێنان
Give the degree of each relationship and say what to draw: (a) an employee is married to another employee of the same company; (b) a pharmacist sells a drug to a customer, and the sale has a date and a price; (c) a course is taught in one room.
پلەی هەر بنووسە و بڵێ چی دەکێشیت: (أ) فەرمانبەرێک هاوسەری فەرمانبەرێکی تری هەمان کۆمپانیایە؛ (ب) دەرمانسازێک دەرمانێک بە کڕیارێک دەفرۆشێت و فرۆشتنەکە بەروار و نرخی هەیە؛ (ج) وانەیەک لە یەک هۆڵدا دەوترێتەوە.
Show answerوەڵامەکە پیشان بدە
- (a) Degree 1: a recursive 1:1 on EMPLOYEE, with the role names husband and wife.
- (b) Degree 3: a ternary PHARMACIST–DRUG–CUSTOMER with the attributes
sale_dateandprice_iqdon the diamond: the price belongs to the whole sale. - (c) Degree 2: a binary N:1 COURSE — taught in — ROOM.
- (أ) پلەی 1:
1:1لەسەر «فەرمانبەر»، بە مێرد و ژن. - (ب) پلەی 3: دەرمانساز–دەرمان–کڕیار بە
sale_dateوprice_iqdلەسەر ئەڵماسییەکە: نرخەکە سەر بە هەموو فرۆشتنەکەیە. - (ج) پلەی 2:
N:1: وانە — دەوترێتەوە لە — هۆڵ.
Using this course's convention, write the pairs for: (a) each football team has 11 to 23 players, and a player plays for at most one team (free players are allowed); (b) each order has at least one order line, and a product may never be ordered.
بە ڕێککەوتنی ئەم کۆرسە جووتەکان بنووسە بۆ: (أ) هەر تیپێکی تۆپی پێ 11 تا 23 یاریزانی هەیە و یاریزانێک لانیزۆر بۆ یەک تیپ یاری دەکات (یاریزانی ئازاد هەیە)؛ (ب) هەر داواکارییەک لانیکەم یەک دێڕی هەیە و بەرهەمێک لەوانەیە هەرگیز داوا نەکرێت.
Show answerوەڵامەکە پیشان بدە
- (a) TEAM (11,23) — has — (0,1) PLAYER. In 1/N it is only 1:N, with a double line at TEAM; the 11 and 23 are lost.
- (b) ORDER (1,N) — contains — (0,N) PRODUCT: min 1 at ORDER (total), min 0 at PRODUCT (partial).
- (أ) تیپ (11,23) — هەیەتی — (0,1) یاریزان. بە 1/N تەنها
1:Nـە، بە هێڵی دووانە لە لای تیپ؛ 11 و 23 ون دەبن. - (ب) داواکاری (1,N) — لەخۆ دەگرێت — (0,N) بەرهەم: کەمترین 1 لە لای داواکاری (تەواو)، کەمترین 0 لە لای بەرهەم (بەشەکی).
A clinic keeps doctors (licence number, specialty) and nurses (ward, shift). Both have a staff number, a name and a phone. Cleaners are staff but neither doctors nor nurses. Draw the hierarchy and give its constraints.
نۆرینگەیەک دکتۆرەکان (ژمارەی مۆڵەت، پسپۆڕی) و پەرستارەکان (بەش، نۆبەت) هەڵدەگرێت. هەردووکیان ژمارەی فەرمانبەری، ناو و مۆبایلیان هەیە. پاککەرەوەکان ستافن بەڵام نە دکتۆرن نە پەرستار. پلەبەندییەکە بکێشە و ڕێساکانی بنووسە.
Show answerوەڵامەکە پیشان بدە
- Generalise DOCTOR and NURSE into STAFF (staff_no, name, phone); the subclasses keep licence_no, specialty and ward, shift.
- Disjoint (d): nobody is both a doctor and a nurse. Partial (single line): cleaners are staff in no subclass.
- «دکتۆر» و «پەرستار» بە دەکەیتە «ستاف» (staff_no، name، phone)؛ licence_no، specialty و ward، shift دەهێڵنەوە.
- جیاکراوە (d): کەس هەم دکتۆر و هەم پەرستار نییە. بەشەکی (هێڵی تاک): پاککەرەوەکان ستافن و لە هیچ نین.
Exam-style questionsپرسیاری شێوەی تاقیکردنەوە
The course's question bank had multiple-choice questions on these topics. Here are new questions in the same style, in our own words.
بانکی پرسیارەکانی کۆرسەکە پرسیاری هەڵبژاردنی زۆری لەسەر ئەم بابەتانە هەبوو. ئەمانە پرسیاری نوێن بە هەمان شێواز، بە وشەی خۆمان.
Summary and reviewکورتە و پێداچوونەوە
- The degree of a relationship is the number of entity types in it: recursive (1), binary (2), ternary (3), n-ary. A relationship is a subset of their Cartesian product.
- A recursive relationship joins an entity type to itself; role names say which line is which. Its rows form a directed graph.
- A ternary fact is not three binaries: the pairs cannot rebuild the triples. A 1 on one side makes the other two the key.
- (min,max) gives exact limits; in this course it stands next to the entity it describes. Min 0 = partial, min ≥ 1 = total.
- Specialisation (top-down) and generalisation (bottom-up) build IS-A hierarchies; subclasses inherit attributes and relationships; constraints: d/o and total (double line)/partial.
- A category is a union of different superclasses (a U in the circle); aggregation boxes a relationship so that it can take part in another one.
- Next: From EER Diagrams to Tables turns every construct of this lesson into SQL tables and practises them on a hospital, a delivery company and an online market.
- دەڵێت چەند جۆری تێیدا بەشدارن: خۆیی (1)، دووانی (2)، سێیانی (3)، فرەلایەنە. بەشێکە لە ئەوان.
- جۆرێکی بە خۆیەوە دەبەستێتەوە؛ دەڵێن کام هێڵ کامەیە. ئاراستەدار پێکدەهێنن.
- ڕاستییەکی سێیانی سێ نییە: جووتەکان ناتوانن سێیانەکان دروست بکەنەوە. 1 لە یەک لا دووەکەی تر دەکاتە .
- (min,max) سنووری ورد دەدات؛ لەم کۆرسەدا لە تەنیشت ئەو کە وەسفی دەکات. کەمترین 0 = بەشەکی، کەمترین 1 یان زیاتر = تەواو.
- (سەرەوە بۆ خوارەوە) و (خوارەوە بۆ سەرەوە) پلەبەندیی IS-A دروست دەکەن؛ و بە میرات وەردەگرن؛ ڕێساکان: d/o و تەواو (هێڵی دووانە)/بەشەکی.
- چەند جیاوازە (U لە ناو بازنەکەدا)؛ دەخاتە ناو سندوقێکەوە بۆ ئەوەی بتوانێت لە تردا بەشدار بێت.
- داهاتوو: لە هێڵکاریی EERـەوە بۆ خشتەکان هەموو پێکهاتەیەکی ئەم وانەیە دەکاتە و لەسەر نەخۆشخانەیەک، کۆمپانیایەکی گەیاندن و بازاڕێکی ئۆنلاین ڕاهێنانیان پێدەکات.
Why can't three binary relationships replace a ternary one?بۆچی سێ پەیوەندیی دووانی ناتوانن جێگەی پەیوەندییەکی سێیانی بگرنەوە؟
They keep only pairs. Joining the pairs back can create triples that never happened, such as (Aram Trading, bolts, School).
تەنها جووت هەڵدەگرن. جووتەکان دەتوانێت سێیانەیەک دروست بکات کە هەرگیز ڕووی نەداوە، وەک (Aram Trading, bolts, School).
What do d, o and a double line mean in an ISA diagram?d، o و هێڵی دووانە لە هێڵکاریی ISAـدا مانای چییە؟
d: an entity is in at most one subclass (disjoint). o: it may be in several (overlapping). Double line from the superclass: every entity must be in some subclass (total).
d: لانیزۆر لە یەک (جیاکراوە). o: دەکرێت لە چەند دانەیەکدا بێت (بەیەکداچوو). هێڵی دووانە لە : هەموو دەبێت لە بێت (تەواو).
When do you need aggregation?کەی پێویستت بە گردکردنەوە هەیە؟
When a fact is about a relationship as a whole, for example 'an employee working on a project uses a machine', or 'only a member may chair the department'.
کاتێک ڕاستییەک دەربارەی بە گشتییە، بۆ نموونە «فەرمانبەرێک کە لەسەر پڕۆژەیەک کار دەکات ئامێرێک بەکار دەهێنێت»، یان «تەنها ئەندامێک دەتوانێت سەرۆکی بەش بێت».
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
From EER Diagrams to Tablesلە هێڵکاریی EERـەوە بۆ خشتەکان
Related lecturesوانە پەیوەندیدارەکان
- From EER Diagrams to Tablesلە هێڵکاریی EERـەوە بۆ خشتەکان
- Database Keysکلیلەکانی بنکەدراوە
- The Database Development Life Cycleسووڕی ژیانی گەشەپێدانی بنکەدراوە
- Relational Algebra and Relational Calculusجەبری پەیوەندیدار و ژمێرکاریی پەیوەندیدار
- Relationships and Referential Integrityپەیوەندییەکان و دروستیی ئاماژەپێدان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- Wikipedia: Enhanced entity–relationship model (subclasses, specialisation, generalisation, inheritance, categories, aggregation; cites Elmasri & Navathe, Fundamentals of Database Systems, ch. 8–9)
- Wikipedia: Entity–relationship model (look-across and same-side cardinality, crow's foot notation, roles)
- Silberschatz, Korth and Sudarshan: Database System Concepts, 7th ed., Chapter 6 slides (roles, non-binary relationships, l..h limits, specialisation, aggregation, reduction to schemas, crow's foot and UML)
- Wikipedia: Class diagram (UML multiplicities, generalisation, role names)
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.