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 لە تەنیشت یەکتر — لەگەڵ ڕاهێنان و پرسیاری شێوەی تاقیکردنەوە.

31 min read34 خولەک خوێندنەوە · 27 stepsهەنگاو

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:

بەو بەردە بناغانە دەتوانیت زۆربەی بکێشیت. بەڵام سێ دۆخی ڕۆژانە بەوانە بە ئاسانی دەرنابڕدرێن:

  1. An employee who manages other employees. Both ends of the line are the same entity type, Staff. Which end is the manager?
  2. A doctor who prescribes a drug to a patient. One fact joins three things at once, not two.
  3. Staff who are either academic or administrative. They share a name and a salary, but each kind has attributes of its own.
  1. فەرمانبەرێک کە سەرپەرشتیی فەرمانبەرانی تر دەکات. هەردوو سەری هێڵەکە هەمان جۆری : «فەرمانبەر». کام سەر بەڕێوەبەرەکەیە؟
  2. دکتۆرێک کە دەرمانێک بۆ نەخۆشێک دەنووسێت. یەک ڕاستی سێ شت پێکەوە دەبەستێتەوە، نەک دوو.
  3. ستافێک کە یان مامۆستان یان کارمەندی کارگێڕی. ناو و مووچەیان هاوبەشە، بەڵام هەر جۆرێکیان تایبەت بە خۆی هەیە.
Definitionپێناسە

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)⁩، و ، و . شاشەکانی داهاتوو یەک بە یەک باسیان دەکەن؛ وانەی داهاتوو دەیانکاتە .

Quick checkپشکنینی خێراWhich situation needs one relationship among THREE entity types?کام دۆخ پێویستی بە یەک لە نێوان سێ جۆری هەیە؟

Degree of a relationshipپلەی پەیوەندی

Definitionپێناسە

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 وەربگرە. هەر ڕێگەیەک بۆ هەڵبژاردنی یەک لە هەر یەکێکیان ئەندامێکی لێکدانی دیکارتیی ئەوانە. تەنها ئەو لێکدانانە هەڵدەگرێت کە بە ڕاستی ڕوویان داوە، بۆیە بەشێکە لەو لێکدانە:

R⊆E1×E2×⋯×EnR \subseteq E_1 \times E_2 \times \cdots \times E_n

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 3×40×25=30003 \times 40 \times 25 = 3000 possible triples, but this month only 120 prescriptions were written. The relationship prescribes holds those 120.

نموونە: نۆرینگەیەک 3 دکتۆر، ⁦40⁩ نەخۆش و ⁦25⁩ دەرمانی هەیە. لێکدانەکە 3×40×25=30003 \times 40 \times 25 = 3000 سێیانەی گونجاو هەڵدەگرێت، بەڵام ئەم مانگە تەنها ⁦120⁩ ڕەچەتە نووسراون. «دەنووسێت» ئەو ⁦120⁩ـە هەڵدەگرێت.

Most relationships are binary; ternary ones are the next most common.زۆربەی دووانین؛ سێیانییەکان لە دوای ئەوانەوە باوترن.
DegreeپلەNameناوExampleنموونە
1unary (recursive)Staff manages Staffفەرمانبەر سەرپەرشتیی فەرمانبەر دەکات
2binaryStudent takes Courseقوتابی وانە دەخوێنێت
3ternaryDoctor prescribes Drug to Patientدکتۆر دەرمان بۆ نەخۆش دەنووسێت
nn-aryLecturer teaches Course in Room at a Time slot (n = 4)مامۆستا وانە لە هۆڵێکدا لە کاتێکی دیاریکراودا دەڵێتەوە ⁦(n = 4)⁩
Quick checkپشکنینی خێراWhat is the degree of 'a supplier supplies a part to a project'?پلەی «دابینکەرێک پارچەیەک بۆ پڕۆژەیەک دابین دەکات» چەندە؟

Recursive relationships and role namesپەیوەندییە خۆییەکان و ناوەکانی ڕۆڵ

Definitionپێناسە

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.

لە کۆمپانیایەک لە هەولێر، هانا سەرپەرشتیی ئارام و شیلان دەکات و ئارامیش سەرپەرشتیی کاروان دەکات. هەر چواریان هەمان جۆرن: «فەرمانبەر». بۆیە «سەرپەرشتی دەکات» دوو هێڵی هەیە کە هەردووکیان دەچنە سەر «فەرمانبەر». بۆ خوێندنەوەی، هەر هێڵێک وەردەگرێت: سەرپەرشتیار لەسەر یەکێکیان و ژێردەست لەسەر ئەوی تر.

Left: the entity STAFF (staff_no underlined, name) joined to the diamond 'manages' by two lines. The upper line is labelled 'supervisor' and 1, the lower line 'subordinate' and N. Right: the rows as a directed graph: Hana points to Aram and Shilan, and Aram points to Karwan.چەپ: قەوارەی «فەرمانبەر» (staff_no هێڵی بەژێردا هاتووە، name) بە دوو هێڵ بە ئەڵماسیی «سەرپەرشتی دەکات»ـەوە بەستراوە. هێڵی سەرەوە «سەرپەرشتیار» و 1ی لەسەرە، هێڵی خوارەوە «ژێردەست» و N. ڕاست: ڕیزەکان وەک گرافێکی ئاراستەدار: هانا ئاماژە بە ئارام و شیلان دەکات و ئارامیش ئاماژە بە کاروان.
A recursive relationship with role names, and the graph its rows form. لەگەڵ و ئەو پێکی دەهێنن.CêIT

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

دەتوانێت هەر ئاراستەدار هەڵبگرێت: هەر و هەر تیرێکە، وەک نیوەی ڕاستی وێنەکە. گەڕانی هەمان بیرۆکەن (گرافی فەزای دۆخەکان).

Quick checkپشکنینی خێراIn STAFF manages STAFF, which mark belongs on the subordinate line?لە «فەرمانبەر سەرپەرشتیی فەرمانبەر دەکات»دا، کام نیشانە دەچێتە سەر هێڵی ژێردەست؟

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)⁩ بۆ ڕۆڵی منداڵ.
Quick checkپشکنینی خێراA family-tree app stores each person's mother. Everyone has exactly one mother; a mother can have many children. What is mother of?ئەپێکی ڕەچەڵەک دایکی هەر کەسێک هەڵدەگرێت. هەموو کەسێک ڕێک یەک دایکی هەیە؛ دایکێک دەتوانێت چەندین منداڵی هەبێت. «دایکی ... یە» چییە؟

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.

ڕاهێنانی گەیاندنی وانەی داهاتوو هەمان شێوەی هەیە: پاکەتێک لەلایەن یەک کڕیارەوە دەنێردرێت و یەک کڕیار وەریدەگرێت. نێرەر و وەرگر لێکیان جیا دەکەنەوە.

Quick checkپشکنینی خێراShilan lives in a house in Duhok and owns two flats in Erbil that she rents out. How many relationships between PERSON and HOUSE does the design need?شیلان لە خانوویەک لە دهۆک دەژی و خاوەنی دوو شوقەیە لە هەولێر کە بە کرێیان دەدات. دیزاینەکە چەند لە نێوان «کەس» و «خانوو»دا پێویستە؟

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:

هەر دەبێت لە ئەوانی تر جیا بکرێتەوە، وەک . ناسێنەری () کەمترین ژمارەی بەشداربووانە کە ئەم کارە دەکەن. بڕیار دەدات کام پێویستە:

RelationshipCardinalityIts 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⁩}: هەر کامیان بێت کار دەکات.
Quick checkپشکنینی خێراLecturer belongs to Department is N:1. Which key identifies one belongs to row?«مامۆستا سەر بە بەشە» N:1ـە. کام یەک «سەر بە»ـی دەناسێنێت؟

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 پێویستی بە خشتەیەکی سێیەم هەیە.

Quick checkپشکنینی خێراA pharmacy sells many drugs and a drug is sold in many pharmacies, each at its own price. Where does price_iqd go?دەرمانخانەیەک چەندین دەرمان دەفرۆشێت و دەرمانێک لە چەندین دەرمانخانەدا دەفرۆشرێت، هەر یەکەیان بە نرخی خۆی. price_iqd دەچێتە کوێ؟

Ternary relationshipsپەیوەندییە سێیانییەکان

Definitionپێناسە

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ـی بۆ ئارام نووسی، لەگەڵ بەروار و بڕێک کە سەر بە هەموو سێیانەکەن. یەک ئەڵماسی هەر سێ جۆرەکەی پێکەوە دەبەستێتەوە.

Left: DOCTOR, PATIENT and DRUG joined to one diamond 'prescribes' marked M, N and P, with the attributes presc_date and quantity on the diamond. Right: the same three entities joined in pairs by three diamonds: treats (doctor–patient), prescribes (doctor–drug) and takes (patient–drug). The note asks whether Hana prescribed Feverol to Aram: the pairs cannot say.چەپ: «دکتۆر»، «نەخۆش» و «دەرمان» بە یەک ئەڵماسیی «دەنووسێت»ـەوە بەستراون کە M، N و Pـی لەسەرە، لەگەڵ خەسڵەتەکانی presc_date و quantity لەسەر ئەڵماسییەکە. ڕاست: هەمان سێ قەوارە بە سێ ئەڵماسی دوو بە دوو بەستراون: چارەسەر دەکات (دکتۆر–نەخۆش)، دەنووسێت (دکتۆر–دەرمان) و وەردەگرێت (نەخۆش–دەرمان). تێبینییەکە دەپرسێت ئایا هانا Feverolـی بۆ ئارام نووسیوە: جووتەکان ناتوانن بیڵێن.
One ternary relationship (left) is not the same as three binary relationships (right).یەک (چەپ) هەمان سێ (ڕاست) نییە.CêIT

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)، هەر سێ پێکەوە.

Quick checkپشکنینی خێراIn the prescription relationship, what does quantity describe?لە ڕەچەتەدا، quantity چی وەسف دەکات؟

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, BridgeAram Trading, boltsbolts, BridgeAram Trading, Bridge
Aram Trading, cables, SchoolAram Trading, cablescables, SchoolAram Trading, School
Dilan Trading, bolts, SchoolDilan Trading, boltsbolts, SchoolDilan 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⁩ بۆ قوتابخانەکە کار دەکات. جووتەکان سێیانەیەکی چوارەمی هەڵە دروست دەکات:

Rebuilding the triples from the three pairsدروستکردنەوەی سێیانەکان لە سێ جووتەکەSQLRuns in the databaseلە ناو بنکەدراوە کار دەکات
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;
Quick checkپشکنینی خێراWhy did the join return (Aram Trading, bolts, School)?بۆچی ⁦(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 لە لای : هەر جووتێکی (قوتابی، وانە) یەک هەیە. نەیاندەتوانی بڵێن «یەک بۆ هەر وانەیەک».

Quick checkپشکنینی خێراIn a pharmacy chain, each pharmacy buys each drug from exactly one wholesaler, but a wholesaler serves many pharmacies and many drugs. How is this modelled?لە زنجیرەیەک دەرمانخانەدا، هەر دەرمانخانەیەک هەر دەرمانێک ڕێک لە یەک فرۆشیاری گەورە دەکڕێت، بەڵام فرۆشیارێکی گەورە خزمەتی چەندین دەرمانخانە و چەندین دەرمان دەکات. چۆن مۆدێل دەکرێت؟

(min,max): at least and at most⁦(min,max)⁩: لانیکەم و لانیزۆر

Definitionپێناسە

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 = «زۆر».

In the last column the 1 or N of the old marks is written at the OTHER end of the line (read across); the double line stays next to the entity.لە دوایین ، 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 ون دەبن
Quick checkپشکنینی خێراStudent (2,8) — takes — (4,N) Course. Which statement is true?قوتابی ⁦(2,8)⁩ — دەخوێنێت — ⁦(4,N)⁩ وانە. کام ڕستە ڕاستە؟

(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⁩ـی مۆدێلی قەوارە و پەیوەندی بە سەر هێڵەکەدا دەخوێنرێنەوە. بۆیە هەمان ڕاستی لە دوو لای پێچەوانەدایە:

Two rows. Top: DEPARTMENT, a diamond 'employs' and LECTURER, with 1 near DEPARTMENT and N near LECTURER and double lines; a note says N sits next to LECTURER but counts the lecturers of one department. Bottom: the same relationship with (2,N) next to DEPARTMENT and (1,1) next to LECTURER; notes say each department employs at least 2 lecturers and each lecturer works in exactly one department, and that 1/N cannot say 'at least two'.دوو ڕیز. سەرەوە: «بەش»، ئەڵماسیی «دایدەمەزرێنێت» و «مامۆستا»، بە 1 لە نزیک «بەش» و N لە نزیک «مامۆستا» و هێڵی دووانە؛ تێبینییەک دەڵێت N لە تەنیشت «مامۆستا»یە بەڵام مامۆستایانی یەک بەش دەژمێرێت. خوارەوە: هەمان پەیوەندی بە (2,N) لە تەنیشت «بەش» و (1,1) لە تەنیشت «مامۆستا»؛ تێبینییەکان دەڵێن هەر بەشێک لانیکەم 2 مامۆستا دادەمەزرێنێت و هەر مامۆستایەک ڕێک لە یەک بەشدا کار دەکات و 1/N ناتوانێت بڵێت «لانیکەم دوو».
The same rule in 1/N (read across) and in (min,max) (next to the entity).هەمان یاسا بە ⁦1/N⁩ (بە سەر هێڵدا) و بە ⁦(min,max)⁩ (لە تەنیشت ).CêIT
Quick checkپشکنینی خێراA diagram uses this course's convention: CUSTOMER (0,N) — places — (1,1) ORDER. What does it say?هێڵکارییەک ڕێککەوتنی ئەم کۆرسە بەکار دەهێنێت: کڕیار ⁦(0,N)⁩ — دادەنێت — ⁦(1,1)⁩ داواکاری. چی دەڵێت؟

(min,max): at least and at most⁦(min,max)⁩: لانیکەم و لانیزۆر

Two slips in the course slidesدوو هەڵە لە سلایدەکانی کۆرسەکەدا

Quick checkپشکنینی خێراWhy should an E-R diagram not show arrows from foreign keys to primary keys?بۆچی نابێت تیر لە بۆ پیشان بدات؟

Specialisation and generalisationتایبەتکردن و گشتاندن

Definitionپێناسە

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.

(لە سەرەوە بۆ خوارەوە) لە «هەژمار»ـەوە دەست پێدەکات، کە و «پاشەکەوت»، «ڕۆژانە» و «دانراوی ماوەدار» دیاری دەکات. (لە خوارەوە بۆ سەرەوە) پێچەوانەکەیە: تێبینی دەکەیت سێ جۆری هاوبەشیان هەیە و لە سەرووی ئەوانەوە دروست دەکەیت. هەردووکیان بە هەمان هێڵکاری کۆتایی دێن؛ وێنە جووڵاوەکە هەردوو ئاراستە پیشان دەدات.

Animation in six steps. 1: ACCOUNT with seven attributes, many of them empty for most accounts. 2: an ISA circle with d and a double line appears under ACCOUNT with three empty subclasses SAVINGS, CURRENT and FIXED DEPOSIT. 3: interest_rate, overdraft_iqd, start_date and maturity_date move down to their subclasses; acct_no, holder and balance_iqd stay on ACCOUNT. 4: dashed arrows show that each subclass inherits the shared attributes. 5: generalisation starts from three separate entity types that each repeat acct_no, holder and balance_iqd. 6: the shared attributes move up into ACCOUNT and the same ISA diagram appears.
Animation in six steps. 1: ACCOUNT with seven attributes, many of them empty for most accounts. 2: an ISA circle with d and a double line appears under ACCOUNT with three empty subclasses SAVINGS, CURRENT and FIXED DEPOSIT. 3: interest_rate, overdraft_iqd, start_date and maturity_date move down to their subclasses; acct_no, holder and balance_iqd stay on ACCOUNT. 4: dashed arrows show that each subclass inherits the shared attributes. 5: generalisation starts from three separate entity types that each repeat acct_no, holder and balance_iqd. 6: the shared attributes move up into ACCOUNT and the same ISA diagram appears.
Specialisation moves the special attributes down; generalisation moves the shared ones up. دادەبەزێنێت؛ هاوبەشەکان بەرز دەکاتەوە.CêIT

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 نا.

Quick checkپشکنینی خێراA design starts with LECTURER and ADMIN_EMPLOYEE and later adds STAFF above them for their common attributes. Which process is this?دیزاینێک بە «مامۆستا» و «کارمەندی کارگێڕی» دەست پێدەکات و دواتر «ستاف» لە سەرووی ئەوانەوە بۆ زیاد دەکات. ئەمە کام پرۆسەیە؟

Extended ER Features || Generalization || Specialization || Aggregation || DBMSSudhakar Atchala · Englishئینگلیزی · 167K viewsبینین · 3.3K likesلایک · Partبەشی 0:45–6:38 (ofلە 8:39)

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بۆماوەی خەسڵەت: ئەوەی ژێرپۆلێک بەخۆڕایی وەریدەگرێت

Definitionپێناسە

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ـی هەیە. جەخت لەسەر ئەوە دەکاتەوە کە جۆرەکان هاوبەشیانە؛ جەخت لەسەر ئەوە دەکاتەوە کە هەر جۆرێک تایبەت دەکات.

Quick checkپشکنینی خێراWhich attributes does a FIXED DEPOSIT entity have? «دانراوی ماوەدار» چ هەیە؟

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 (کەسێک دەتوانێت هەم فەرمانبەر بێت هەم قوتابیی هەمان زانکۆ).
  • دەبێت هەموو لە بێت؟ بەڵێ ← تەواو، هێڵی دووانە لە بۆ بازنەکە (هەموو فەرمانبەرێک یان مامۆستایە یان کارگێڕی). نەخێر ← بەشەکی، هێڵی تاک (میوانێک کەسە بەڵام نە فەرمانبەرە نە قوتابی).
PERSON (person_id underlined, name, date_of_birth) is joined by a single line to a circle with o, which joins STAFF (salary_iqd) and STUDENT (study_year). STAFF is joined by a double line to a circle with d, which joins ACADEMIC (rank) and ADMINISTRATIVE (office). Notes explain o, d, the single line (partial) and the double line (total).«کەس» (person_id هێڵی بەژێردا هاتووە، name، date_of_birth) بە هێڵێکی تاک بە بازنەیەکی o ـەوە بەستراوە کە «فەرمانبەر» (salary_iqd) و «قوتابی» (study_year) دەبەستێتەوە. «فەرمانبەر» بە هێڵێکی دووانە بە بازنەیەکی d ـەوە بەستراوە کە «مامۆستا» (rank) و «کارگێڕی» (office) دەبەستێتەوە. تێبینییەکان o، d، هێڵی تاک (تایبەتکردنی بەشەکی) و هێڵی دووانە (تایبەتکردنی تەواو) ڕوون دەکەنەوە.
A two-level ISA hierarchy: overlapping and partial at the top, disjoint and total below.پلەبەندییەکی ISA بە دوو ئاست: بەیەکداچوو و بەشەکی لە سەرەوە، جیاکراوە و تەواو لە خوارەوە.CêIT
Quick checkپشکنینی خێراSome persons in the database are neither staff nor students (visitors). How is the line from PERSON to its circle drawn?هەندێک کەس لە نە فەرمانبەرن نە قوتابی (میوانەکان). هێڵی نێوان «کەس» و بازنەکەی چۆن دەکێشرێت؟

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.

نموونەیەکی باو: هەر فەرمانبەرێکی لقی بانکێک یان کاشێرە، یان فەرمانبەری قەرزە، یان بەڕێوەبەرە؛ بۆ هەر کەسێک یەک پیشە. ئەمە جیاکراوەیە (یەک پیشە) و تەواوە (هەمووان یەکێکیان هەیە). کە بە دروست کرابێت زۆرجار تەواوە: «ستاف» کە لە مامۆستایان و کارمەندانی کارگێڕی دروست کراوە ڕێک ئەوان لەخۆ دەگرێت.

Quick checkپشکنینی خێراA library item is a book, a journal or a DVD; nothing else is kept, and nothing is two of these at once. How is the specialisation drawn?هەر شتێکی کتێبخانەیەک کتێب، گۆڤار یان DVDـیە؛ هیچی تر هەڵناگیرێت و هیچ شتێک لە هەمان کاتدا دووانیان نییە. چۆن دەکێشرێت؟

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.

ئەم جۆرە بە سروشتی جیاکراوەیە (لە یەک کاتدا یەک نازناو) و تەواوە ئەگەر هەموو مامۆستایەک نازناوێکی هەبێت. تەنها کاتێک شایەنی کێشانە کە جیاواز بن: بۆ نموونە، تەنها پرۆفیسۆرەکان دەتوانن سەرپەرشتیی قوتابیانی دکتۆرا بکەن.

Quick checkپشکنینی خێراACADEMIC is specialised by the value of title. Can one academic be in two of these subclasses at the same time?«مامۆستا» بەپێی نرخی title تایبەت کراوە. دەکرێت مامۆستایەک لە هەمان کاتدا لە دوو لەم بێت؟

Specialisation and generalisationتایبەتکردن و گشتاندن

Categories (union types)جۆرەکانی یەکگرتن

Definitionپێناسە

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 (national_id underlined) and COMPANY (reg_no underlined) are joined to a circle with a U sign. A single line joins the circle to OWNER (owner_id underlined): a partial category. OWNER 1 — owns — N VEHICLE (plate_no underlined), with a double line on the vehicle side. Notes say each owner is a person or a company, never both, that the single line means not every person or company is an owner, and that owner_id is a new surrogate key.«کەس» (national_id هێڵی بەژێردا هاتووە) و «کۆمپانیا» (reg_no هێڵی بەژێردا هاتووە) بە بازنەیەکی نیشانەی U ـەوە بەستراون. هێڵێکی تاک بازنەکە بە «خاوەن» (owner_id هێڵی بەژێردا هاتووە) دەبەستێتەوە: بەشەکی. «خاوەن» 1 — خاوەنیەتی — N «ئۆتۆمبێل» (plate_no هێڵی بەژێردا هاتووە)، بە هێڵی دووانە لە لای ئۆتۆمبێل. تێبینییەکان دەڵێن هەر خاوەنێک یان کەسە یان کۆمپانیا، هەرگیز هەردووکیان نا؛ هێڵی تاک واتە هەموو کەس و کۆمپانیایەک خاوەن نییە؛ owner_id کلیلێکی دەستکردی نوێیە.
A category: OWNER is a person or a company.: «خاوەن» یان کەسە یان کۆمپانیا.CêIT

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 (کلیلی دەستکرد)؛ وەشانی خشتە پیشانی دەدات. هەندێک کتێب حاڵەتی پێچەوانەش پیشان دەدەن، : مامۆستایەک کە بە دامەزراندنی هاوبەش لە دوو کۆلێژدا کار دەکات سەر بە هەردووکیانە، هاوبەشی ئەو دووانە.

Quick checkپشکنینی خێراWhy does OWNER need its own key, owner_id?بۆچی «خاوەن» پێویستی بە تایبەت بە خۆی، ⁦owner_id⁩، هەیە؟

Aggregation: a relationship inside a boxگردکردنەوە: پەیوەندییەک لە ناو سندوقێکدا

Definitionپێناسە

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.

چارەسەری دەکات: سندوقێک بە دەوری «کار دەکات لەسەر» و دوو بکێشە و سندوقەکە وەک ئاستبەرز ببینە. ئینجا «بەکار دەهێنێت» سندوقەکە بە «ئامێر»ـەوە دەبەستێتەوە: هەر کارێکی دیاریکراو (فەرمانبەر، پڕۆژە) هەندێک ئامێر بەکار دەهێنێت.

Animation in five steps. 1: EMPLOYEE M — works on — N PROJECT. 2: a relationship 'uses' drawn only between EMPLOYEE and MACHINE, with the question 'for which project?'. 3: a dashed box starts around EMPLOYEE, works on and PROJECT. 4: the box is closed and labelled 'aggregation: works on'. 5: a diamond 'uses' joins the box to MACHINE; the line touches the box, not the inner diamond.
Animation in five steps. 1: EMPLOYEE M — works on — N PROJECT. 2: a relationship 'uses' drawn only between EMPLOYEE and MACHINE, with the question 'for which project?'. 3: a dashed box starts around EMPLOYEE, works on and PROJECT. 4: the box is closed and labelled 'aggregation: works on'. 5: a diamond 'uses' joins the box to MACHINE; the line touches the box, not the inner diamond.
Aggregation: the works-on relationship, boxed with its entities, takes part in 'uses'.: «کار دەکات لەسەر» لەگەڵ لە ناو سندوقدا، لە «بەکار دەهێنێت»دا بەشدار دەبێت.CêIT

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.

ئێستا یاساکە بەشێکە لە هێڵکارییەکە: ئامێر تەنها لە ناو کارێکی دیاریکراوی هەبوودا بەکار دەهێنرێت. هێڵی «بەکار دەهێنێت» بەر سندوقەکە دەکەوێت، نەک بەر ئەڵماسییەکەی ناوەوە. فەرمانبەر–پڕۆژە–ئامێر بە تەنها ئەمە ناڵێت: ڕێگە دەدات ئامێرێک بۆ پڕۆژەیەک بەکار بهێنرێت کە فەرمانبەرەکە لەسەری کار ناکات و کارێکی بێ ئامێریش شوێنی نابێت.

Quick checkپشکنینی خێراWhat does the box around works on guarantee?سندوقەکەی دەوری «کار دەکات لەسەر» چی دەستەبەر دەکات؟

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.

چاوگ زۆرجار مانای دەدات. چاوگ کارێکە کە وەک ناو بەکار دێت: گەیاندن، وانەوتنەوە. «کاڵاکان بۆ کڕیاران دەنێردرێن و گەیاندنەکە لەلایەن شۆفێرێکی گەیاندنەوە ئەنجام دەدرێت.» گەیاندنەکە «دەنێردرێت بۆ»یە (کاڵا–کڕیار) کە وەک شتێک مامەڵەی لەگەڵ دەکرێت؛ «ئەنجام دەدرێت لەلایەن» ئەو سندوقە بە «شۆفێر»ـەوە دەبەستێتەوە.

Quick checkپشکنینی خێرا'Students enrol in courses, and each enrolment is approved by an adviser.' Which design fits?«قوتابیان لە وانەکاندا ناو دەنووسن و هەر ناونووسینێک لەلایەن ڕاوێژکارێکەوە پەسەند دەکرێت.» کام دیزاین گونجاوە؟

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.

ئەم کۆرسە بە دەکێشێت (هەموو هێماکانی). ئامرازەکانی دیزاین و کتێبەکانی تر یان بەکار دەهێنن. خشتەی خوارەوە هەمان پێکهاتەکان بە هەر سێکیان پیشان دەدات.

A table with four columns: construct, Chen, crow's foot, UML class diagram. Rows: entity and key (STUDENT with underlined student_id; a box with student_id PK; a class with student_id {id}); weak entity (double rectangle VISIT with dashed visit_no; a box Visit with patient_id PK FK and visit_no PK; Patient joined to Visit with a filled diamond, 1 and 0..*); relationship with an attribute (takes with an oval grade, M and N; a middle entity Enrolment with grade between Student and Course; an association class Takes with grade); 1:N mandatory/optional (DEPT 1 — employs — N LECTURER with a double line on the lecturer side; two bars at Dept and ring plus crow's foot at Lecturer; 1 and 0..*); M:N (STUDENT M — takes — N COURSE, double line at COURSE; bar plus crow's foot at Student and ring plus crow's foot at Course; 1..* and 0..*).خشتەیەک بە چوار ستوون: پێکهاتە، Chen، پێی قەلەڕەش، هێڵکاریی کلاسی UML. ڕیزەکان: قەوارە و کلیل (قوتابی بە student_idـی هێڵ لە ژێردراو؛ سندوقێک بە student_id PK؛ کلاسێک بە student_id {id})؛ قەوارەی لاواز (لاکێشەی دووهێڵیی سەردان بە visit_noـی پچڕپچڕ؛ سندوقی Visit بە patient_id PK FK و visit_no PK؛ Patient بە ئەڵماسیی پڕ بە Visitـەوە بەستراوە، 1 و 0..*)؛ پەیوەندی بە خەسڵەتەوە (دەخوێنێت بە هێلکەیی grade، M و N؛ قەوارەیەکی ناوەندی ناونووسین بە grade لە نێوان Student و Course؛ کلاسی Takes (association class) بە grade)؛ 1:N ناچاری/ئارەزوومەندانە (بەش 1 — دادەمەزرێنێت — N مامۆستا بە هێڵی دووانە لە لای مامۆستا؛ دوو هێڵ لە لای Dept و بازنە و پێی قەلەڕەش لە لای Lecturer؛ 1 و 0..*)؛ M:N (قوتابی M — دەخوێنێت — N وانە، هێڵی دووانە لە لای وانە؛ هێڵ و پێ لە لای Student و بازنە و پێ لە لای Course؛ 1..* و 0..*).
The same five constructs in Chen, crow's foot and UML notation.هەمان پێنج پێکهاتە بە ، و UML.CêIT
  • 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..* and 1..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 بە سەر هێڵدا دەخوێنرێنەوە. دەچنە ناو پەیوەندی کە بە هێڵێکی پچڕپچڕ بەستراوە.
Quick checkپشکنینی خێراIn crow's foot, one end of a line shows a ring and a crow's foot. What does it mean?لە ، سەرێکی هێڵێک بازنەیەک و پێی قەلەڕەشێک پیشان دەدات. واتای چییە؟

Three ways of drawing, one pageسێ شێوازی کێشان لە یەک لاپەڕەدا

Multi-valued, ISA and recursive in three notationsخەسڵەتی فرەنرخ، ISA و پەیوەندیی خۆیی بە سێ شێواز

A second table with the same four columns. Multi-valued attribute: STUDENT with a double oval phone; a separate Phone box joined to Student with two bars and ring plus crow's foot; a class Student with phone [0..*]. Specialisation: ACCOUNT with a d circle and a double line to SAVINGS and CURRENT; an Account box joined by 1:1 lines to Savings and Current boxes that share acct_no as PK FK; a UML hollow triangle pointing from Savings and Current to Account, with {disjoint, complete}. Recursive relationship: STAFF with a manages diamond and the roles supervisor (1) and subordinate (N); a Staff box with a line back to itself; a UML Staff class with a self-association labelled supervisor 0..1 and subordinate 0..*.خشتەیەکی دووەم بە هەمان چوار ستوون. خەسڵەتی فرەنرخ: قوتابی بە هێلکەیی دووانەی phone؛ سندوقێکی جیای Phone کە بە دوو هێڵ و بازنە و پێ بە Studentـەوە بەستراوە؛ کلاسی Student بە phone [0..*]. تایبەتکردن: هەژمار بە بازنەی d و هێڵی دووانە بۆ پاشەکەوت و ڕۆژانە؛ سندوقی Account بە هێڵی 1:1 بە سندوقەکانی Savings و Currentـەوە بەستراوە کە acct_no وەک PK FK هاوبەشن؛ سێگۆشەیەکی بەتاڵی UML لە Savings و Currentـەوە ڕوو لە Account، بە {disjoint, complete}. پەیوەندیی خۆیی: فەرمانبەر بە ئەڵماسیی سەرپەرشتی دەکات و ڕۆڵەکانی سەرپەرشتیار (1) و ژێردەست (N)؛ سندوقی Staff بە هێڵێک کە دەگەڕێتەوە بۆ خۆی؛ کلاسی Staffـی UML بە پەیوەندییەکی خۆیی کە supervisor 0..1 و subordinate 0..*ـی لەسەرە.
Multi-valued attributes, specialisation and recursive relationships in the three notations.، و بە سێ شێوازەکە.CêIT

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..*) و وەک هێلکەیی و هێڵی خاڵخاڵ.

Quick checkپشکنینی خێراWhich notation shows inheritance with a hollow triangle pointing to the superclass?کام شێواز بە سێگۆشەیەکی بەتاڵ پیشان دەدات کە ڕووی لە ؟

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ڕاهێنان

ExerciseڕاهێنانDegree and rolesپلە و ڕۆڵەکان

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_date and price_iqd on 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: وانە — دەوترێتەوە لە — هۆڵ.
ExerciseڕاهێنانWrite the (min,max) pairsجووتەکانی ⁦(min,max)⁩ بنووسە

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 لە لای بەرهەم (بەشەکی).
ExerciseڕاهێنانSpecialise or generalise?تایبەت بکەیت یان گشتی؟

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.

بانکی پرسیارەکانی کۆرسەکە پرسیاری هەڵبژاردنی زۆری لەسەر ئەم بابەتانە هەبوو. ئەمانە پرسیاری نوێن بە هەمان شێواز، بە وشەی خۆمان.

Quick checkپشکنینی خێراEvery vehicle of a transport company is a car, a bus or a lorry, never two of these, and nothing else is kept. Which specialisation is this?هەموو ئۆتۆمبێلێکی کۆمپانیایەکی گواستنەوە سواری، پاس یان بارهەڵگرە، هەرگیز دووانیان نا و هیچی تر هەڵناگیرێت. ئەمە کام ؟

Quick checkپشکنینی خێراA patient's visits are a weak entity of PATIENT. What is the usual cardinality of PATIENT — has — VISIT?سەردانەکانی نەخۆشێک «نەخۆش»ن. ئاسایی «نەخۆش — هەیەتی — سەردان» چییە؟

Quick checkپشکنینی خێراDilan has a BSc, an MSc and a PhD. What kind of attribute is 'degree'?دیلان بەکالۆریۆس، ماستەر و دکتۆرای هەیە. «بڕوانامە» چ جۆرە ؟

Quick checkپشکنینی خێراMEMBER borrows BOOK in a library. Which of these is an attribute of the relationship, not of an entity?لە کتێبخانەیەکدا «ئەندام کتێب بە قەرز دەبات». کامیان ، نەک هی ؟

Quick checkپشکنینی خێراIn this course's convention: PATIENT (1,1) — stays in — (0,N) WARD. How is the same rule drawn with 1/N and participation lines?بە ڕێککەوتنی ئەم کۆرسە: نەخۆش ⁦(1,1)⁩ — تێیدا دەمێنێتەوە — ⁦(0,N)⁩ قاوش. هەمان یاسا بە ⁦1/N⁩ و هێڵەکانی بەشداری چۆن دەکێشرێت؟

Quick checkپشکنینی خێراA ternary supervises joins STUDENT (60 entities), LECTURER (25) and TOPIC (40). Each student does exactly one graduation project, so each student appears in at most one triple. At most how many triples can supervises hold? «سەرپەرشتی دەکات» قوتابی (⁦60⁩ )، مامۆستا ⁦(25)⁩ و بابەت ⁦(40)⁩ پێکەوە دەبەستێتەوە. هەر قوتابییەک ڕێک یەک پڕۆژەی دەرچوون دەکات، بۆیە هەر قوتابییەک لانیزۆر لە یەک سێیانەدا دەردەکەوێت. «سەرپەرشتی دەکات» لانیزۆر چەند سێیانە هەڵدەگرێت؟

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ـەوە بۆ خشتەکان هەموو پێکهاتەیەکی ئەم وانەیە دەکاتە و لەسەر نەخۆشخانەیەک، کۆمپانیایەکی گەیاندن و بازاڕێکی ئۆنلاین ڕاهێنانیان پێدەکات.
Review questionsپرسیارەکانی پێداچوونەوە
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زاراوە سەرەکییەکان

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

From EER Diagrams to Tablesلە هێڵکاریی EERـەوە بۆ خشتەکان

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

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