Entity-Relationship Modelنموذج الكيان والعلاقة
مقدمة الفصل
ماذا ستتعلم في هذا الفصل
- The design phases and the steps of building a database; data models and the ER model.
- Entity sets, relationship sets, degree, mapping cardinalities and the kinds of attributes.
- Existence dependence, weak entities, and how ER diagrams draw entities, relationships, roles and constraints.
- Cardinality and participation in Chen and crow's foot notation.
- Reduction to relation schemas; specialization, generalization, completeness and disjointness; aggregation; design issues and UML.
أقسام الفصل
- 1Design phases and database design stepsمراحل التصميم وخطوات بناء القاعدة
- 2Data models and the ER modelنماذج البيانات ونموذج الكيان والعلاقة
- 3Entity sets and relationship setsمجموعات الكيانات والعلاقات
- 4Mapping cardinality constraintsأنماط التعدد
- 5Kinds of attributesأنواع الصفات
- 6Existence dependence and weak entitiesالاعتماد في الوجود والكيانات الضعيفة
- 7ER diagrams: entities, relationships, roles and namingمخطط الكيان والعلاقة: الرموز والأدوار والتسمية
- 8Participation and minimum cardinalityالمشاركة والحد الأدنى للتعدد
- 9Reduction to relation schemasالتحويل إلى مخططات علاقات
- 10Non-binary relationshipsالعلاقات غير الثنائية
- 11Specialization, generalization and their constraintsالتخصيص والتعميم وقيودهما
- 12Aggregationالتجميع
- 13Design issues, decisions and UMLقضايا التصميم وقراراته وUML
تلميح: استخدم أسهم لوحة المفاتيح للتنقل بين الشرائح.
Design phasesمراحل التصميم
Design phases (slides 3–4)
- 1
Characterize fully the data needs of the prospective database users.
- 2
Choose a data model and translate the requirements into a conceptual schema (which also indicates the functional requirements — the operations performed on the data).
- 3
Logical design — the database schema: how data is structured logically (entities, attributes, keys, relationships).
- 4
Physical design — the physical layout: how data will be stored (storage, performance).
Logical design involves two decisions (slide 4)
- Business decision — what attributes should we record in the database?
- Computer Science decision — what relation schemas should we have and how should the attributes be distributed among the various relation schemas?
Steps in building a database (slide 5)
- 1
Understand the real-world domain
- 2
Specify it with a conceptual model (ER)
- 3
Translate to the DBMS model (relational)
- 4
Create the schema (DDL)
- 5
Load data (DML)
Design approaches (slide 6)
- Entity Relationship Model (covered in this chapter) — models an enterprise as a collection of entities and relationships, represented diagrammatically by an entity-relationship diagram.
- Normalization Theory (Chapter 6) — formalize what designs are bad, and test for them.
Data models and the ER modelنموذج الكيان والعلاقة
The data model (slide 8)
- A plan or blueprint for a database design.
- More generalized and abstract than a database design.
- Easier to change than a database design — the place to work through conceptual problems.
- Data modeling operates at a high level, starting with conceptual models that capture the essential data and relationships without worrying about technical implementation.
The three basic concepts of the ER model (slide 9)
- entity sets
- relationship sets
- attributes
ER model — database modeling (slide 9)
- The ER data model was developed to facilitate database design by allowing specification of an enterprise schema that represents the overall logical structure of a database.
- It is very useful in mapping the meanings and interactions of real-world enterprises onto a conceptual schema; because of this, many database-design tools draw on concepts from the ER model.
- Its diagrammatic representation, the ER diagram, can express the overall logical structure of a database graphically.
A "thing" or "object" in the enterprise that is distinguishable from other objects, described by a set of attributes.
An association among several entities.
Entity setsمجموعات الكيانات
Entityكيان
- An object that exists and is distinguishable from other objects.
- Example: a specific person, company, event, plant.
Entity setمجموعة كيانات
- A set of entities of the same type that share the same properties.
- Example: the set of all persons, companies, trees, holidays.
- An entity is represented by a set of attributes: instructor = (ID, name, street, city, salary); course = (course_id, title, credits).
- A subset of the attributes forms a primary key, uniquely identifying each member of the set.
Relationship sets and degreeمجموعات العلاقات
Entity sets and relationship sets
An association among several entities — student 44553 (Peltier) advisor instructor 22222 (Einstein).
A mathematical relation among n ≥ 2 entities, each taken from entity sets: {(e1, …, en) | e1 ∈ E1, …, en ∈ En} — e.g., (44553, 22222) ∈ advisor.
- An attribute can be associated with a relationship set: advisor may have a date (when the student started with the advisor).
- Binary relationships involve two entity sets; most relationship sets are binary.
- proj_guide — students work on research projects under an instructor — is a ternary relationship between instructor, student and project.
Example: instructor, student and advisorمثال advisor
Entity sets and relationship sets
| instructor_ID | instructor_name |
|---|---|
| 76766 | Crick |
| 45565 | Katz |
| 10101 | Srinivasan |
| 98345 | Kim |
| 76543 | Singh |
| 22222 | Einstein |
| student-ID | student_name |
|---|---|
| 98988 | Tanaka |
| 12345 | Shankar |
| 00128 | Zhang |
| 76543 | Brown |
| 76653 | Aoi |
| 23121 | Chavez |
| 44553 | Peltier |
| instructor | student | date (slide 14) |
|---|---|---|
| 76766 Crick | 98988 Tanaka | 3 May 2008 |
| 45565 Katz | 12345 Shankar | 10 June 2007 |
| 45565 Katz | 00128 Zhang | 12 June 2006 |
| 10101 Srinivasan | 76543 Brown | 6 June 2009 |
| 98345 Kim | 76653 Aoi | 30 June 2007 |
| 76543 Singh | 23121 Chavez | 31 May 2007 |
| 22222 Einstein | 44553 Peltier | 4 May 2006 |
Mapping cardinalitiesأنماط التعدد
Mapping cardinality constraints
Express the number of entities to which another entity can be associated via a relationship set; for a binary relationship set they are one to one, one to many, many to one, or many to many.
- Mapping cardinalities are most useful in describing binary relationship sets (slide 16).
- Note: some elements in A and B may not be mapped to any elements in the other set.
- In diagrams: directed line (→) = "one"; undirected line (—) = "many" (slide 37).
| Figureالشكل | Linesالخطوط | Not mappedغير مرتبط |
|---|---|---|
| (a) One to one (slide 17) |
| a4 |
| (b) One to many (slide 17) |
| لا تذكر الشرائح شيئًا هنا. |
| (a) Many to one (slide 18) |
| لا تذكر الشرائح شيئًا هنا. |
| (b) Many to many (slide 18) |
| b4 |
Cardinality examples with advisorأمثلة التعدد
Mapping cardinality constraints
| Cardinalityالتعدد | An instructor is associated with…المدرس يرتبط بـ | A student is associated with…الطالب يرتبط بـ |
|---|---|---|
| One-to-many | Several (including 0) students | At most one instructor |
| Many-to-one | At most one student | Several (including 0) instructors |
| Many-to-many | Several (possibly 0) students | Several (possibly 0) instructors |
| One-to-one (slide 37) | لا تذكر الشرائح شيئًا هنا. | At most one instructor |
Kinds of attributesأنواع الصفات
| Kindالنوع | Meaningالمعنى | Exampleمثال |
|---|---|---|
| Composite identifier | Primary key composed of more than one attribute | لا تذكر الشرائح شيئًا هنا. |
| Composite attribute | Can be subdivided to yield additional attributes | Address, phone number |
| Simple attribute | Cannot be subdivided | Age, gender, marital status |
| Single-valued attribute | Has only a single value | A part's serial number (such as SE-08-02-189935) |
| Multivalued attribute | Has many values (should not be implemented in an RDBS) |
|
| Derived attribute | Value calculated from other attributes |
|
Handling a multivalued attribute (slide 20)
- 1) Several new attributes, one for each component — can cause structural problems.
- 2) A new entity composed of the original multivalued attribute's components — the best option.
Drawing complex attributesرسم الصفات
Kinds of attributes
composite attributes
name
address
street
instructor
name
address
street
- Composite: components indented under the attribute (name, address, street).
- Multivalued: in braces — { phone_number }.
- Derived: followed by parentheses — age ( ).
- Primary key: underlined — ID.
Existence dependence and weak entitiesالكيان الضعيف
Existence dependenceمعتمد في وجوده
- Exists only when associated with another related entity occurrence.
- A foreign key attribute cannot be null (pk of the other table).
Existence independenceمستقل في وجوده
- Exists apart from all of its related entities.
- Called a strong or regular entity.
An entity whose existence depends upon another entity. Conditions: 1. existence-dependent on its parent entity; 2. inherits at least part of its primary key from its parent entity.
A weak entity: EMPLOYEE has DEPENDENTمثال الكيان الضعيف
Existence dependence and weak entities
| EMPLOYEE | DEPENDENT | |
|---|---|---|
| Chen model |
|
|
| Crow's foot model | Two bars and (1,1) on its side of has | Oval with crow's foot and (0,N) on its side of has |
| Attributes | EMP_NUM (PK), EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_DOB, EMP_HIREDATE | DEP_NUM (PK), EMP_NUM (PK, FK1), DEP_FNAME, DEP_DOB |
| EMP_NUM | EMP_LNAME | EMP_FNAME | EMP_INITIAL | EMP_DOB | EMP_HIREDATE |
|---|---|---|---|---|---|
| 1001 | Callifante | Jeanine | J | 12-Mar-64 | 25-May-97 |
| 1002 | Smithson | William | K | 23-Nov-70 | 28-May-97 |
| 1003 | Washington | Herman | H | 15-Aug-68 | 28-May-97 |
| 1004 | Chen | Lydia | B | 23-Mar-74 | 15-Oct-98 |
| 1005 | Johnson | Melanie | لا تذكر الشرائح شيئًا هنا. | 28-Sep-66 | 20-Dec-98 |
| 1006 | Ortega | Jorge | G | 12-Jul-79 | 05-Jan-02 |
| 1007 | O'Donnell | Peter | D | 10-Jun-71 | 23-Jun-02 |
| 1008 | Brzenski | Barbara | A | 12-Feb-70 | 01-Nov-03 |
| EMP_NUM | DEP_NUM | DEP_FNAME | DEP_DOB |
|---|---|---|---|
| 1001 | 1 | Annelise | 05-Dec-97 |
| 1001 | 2 | Jorge | 30-Sep-02 |
| 1003 | 1 | Suzanne | 25-Jan-04 |
| 1006 | 1 | Carlos | 25-May-01 |
| 1008 | 1 | Michael | 19-Feb-95 |
| 1008 | 2 | George | 27-Jun-98 |
| 1008 | 3 | Katherine | 18-Aug-03 |
Expressing weak entity sets (slide 50)
- A weak entity set is depicted via a double rectangle.
- The discriminator of a weak entity set is underlined with a dashed line.
- The relationship set connecting the weak entity set to the identifying strong entity set is depicted by a double diamond.
- Primary key for section — (course_id, sec_id, semester, year): section is weak, identified through sec_course by course.
The university design: entity sets and relationship setsتصميم الجامعة
ER diagrams: entities, relationships, roles and naming
| Entity set | Attributes |
|---|---|
| classroom | building, room_number, capacity |
| department | dept_name, building, budget |
| course | course_id, title, credits |
| instructor | ID, name, salary |
| section | course_id, sec_id, semester, year |
| student | ID, name, tot_cred |
| time_slot | time_slot_id, {(day, start_time, end_time)} |
| Relationship setمجموعة العلاقة | Relates (slide 27)تربط | Lines in the E-R diagram (slide 51)خطوطها في المخطط |
|---|---|---|
| inst_dept | instructors with departments |
|
| stud_dept | students with departments |
|
| teaches | instructors with sections |
|
| takes | students with sections, with a descriptive attribute grade |
|
| course_dept | courses with departments |
|
| sec_course | sections with courses |
|
| sec_class | sections with classrooms |
|
| sec_time_slot | sections with time slots |
|
| advisor | students with instructors |
|
| prereq | courses with prerequisite courses | course twice, with the roles course_id and prereq_id |
- On slide 51, section is a double rectangle (a weak entity set) and its sec_id, semester and year are underlined with a dashed line (the discriminator).
The university schema diagramمخطط الجامعة
ER diagrams: entities, relationships, roles and naming
| Relation | Attributes | Arrows |
|---|---|---|
| takes | ID, course_id, sec_id, semester, year, grade |
|
| student | ID, name, dept_name, tot_cred | dept_name → department |
| section | course_id, sec_id, semester, year, building, room_no, time_slot_id |
|
| course | course_id, title, dept_name, credits | dept_name → department |
| department | dept_name, building, budget | لا تذكر الشرائح شيئًا هنا. |
| advisor | s_id, i_id |
|
| time_slot | time_slot_id, day, start_time, end_time | لا تذكر الشرائح شيئًا هنا. |
| classroom | building, room_no, capacity | لا تذكر الشرائح شيئًا هنا. |
| prereq | course_id, prereq_id |
|
| instructor | ID, name, dept_name, salary | dept_name → department |
| teaches | ID, course_id, sec_id, semester, year |
|
ER diagram basicsأساسيات المخطط
ER diagrams: entities, relationships, roles and naming
Entity Relationship Diagram (slide 29)
- A graphical representation of entities and their relationships in a database structure.
- Describes the conceptual database as viewed by the end user: entities, attributes (keys and non-key), relationships.
Naming conventions (slide 30)
- Entity names: descriptive, familiar terminology, singular.
- Attribute names: descriptive of the data; proper naming facilitates communication and promotes self-documentation.
- All lowercase letters for the class assignments.
An entity set; attributes listed inside; underline = primary key.
A relationship set.
Entity sets of a relationship need not be distinct; each occurrence plays a "role" — in prereq, "course_id" and "prereq_id" are roles.
The examples drawn on slides 31–34
- Slide 31: the rectangles instructor (ID, name, salary) and student (ID, name, tot_cred), with ID underlined.
- Slide 33: the diamond advisor joins the two rectangles by lines.
- Slide 34 (relationship sets with attributes): the attribute date is drawn in a box joined to the advisor diamond by a dashed line.
Summary of E-R symbolsملخص الرموز
ER diagrams: entities, relationships, roles and naming
| Symbolالرمز | Meaningالمعنى |
|---|---|
| Rectangle | Entity |
| Double rectangle | Weak entity |
| Diamond | Relationship |
| Double diamond | Identifying relationship |
| Oval | Attribute |
| Oval with a solid line inside | Key attribute |
| Oval with a dashed line inside | Partial key, discriminator |
| Oval joined to smaller ovals | Composite attribute |
| Double oval | Multivalued attribute |
| Dotted oval | Derived attribute |
| Double line | Total participation |
| 1, 2, N, n, m | Cardinality expressions |
| Symbolالرمز | Meaningالمعنى |
|---|---|
| Rectangle | Entity set |
| Diamond | Relationship set |
| Double rectangle | Weak entity set |
| Double diamond | Identifying relationship set for a weak entity set |
| Double line | Total participation of an entity set in a relationship |
| Solid underline | Primary key |
| Dashed underline | Discriminating attribute of a weak entity set |
| {A3} / A4() | Multivalued attribute / derived attribute |
| l..h on a line | Cardinality limits |
| Arrow (→) / line (—) | One / many |
| Triangle (ISA) | Generalization or specialization |
Total and partial participationالمشاركة
Participation and minimum cardinality
The minimum number of entity instances that must participate in a relationship — generally 0 (partial / optional) or 1 (total / mandatory).
Total (mandatory)كلية
- Indicated by a double line.
- Every entity participates in at least one relationship.
- Student in advisor: every student must have an associated instructor.
Partial (optional)جزئية
- Some entities may not participate in any relationship.
- Instructor in advisor: an instructor may advise no student.
Chen l..h and crow's foot notationChen وقدم الغراب
Participation and minimum cardinality
Chen notation l..h (slide 43)
- l = minimum, h = maximum cardinality.
- Minimum 1 → total participation; maximum 1 → at most one relationship; maximum * → no limit.
- Example: an instructor can advise 0 or more students (0..*); a student must have 1 advisor and cannot have multiple advisors (1..1).
Crow's foot (slides 44–45)
- Minimum 0 (optional): an oval next to the optional entity.
- Minimum 1 (mandatory): a vertical hash mark next to the required entity.
- Next to B, the symbol farther from B gives the minimum and the symbol touching B the maximum number of records of "B" that can be associated with one record of "A" (slide 45).
Crow's foot symbols and examplesرموز قدم الغراب
Participation and minimum cardinality
| Symbolالرمز | Meaningالمعنى | Numeric meaningالمعنى العددي |
|---|---|---|
| Two bars | Mandatory–One | Exactly one |
| Bar and crow's foot | Mandatory–Many | One or more |
| Circle and bar | Optional–One | Zero or one |
| Circle and crow's foot | Optional–Many | Zero or more |
| Case | Next to A | Next to B |
|---|---|---|
| (b) R is 1:N | bar, then circle | crow's foot, then bar |
| (c) R is 1:1 | bar, then bar | bar, then circle |
| (d) R is M:N | crow's foot, then circle | crow's foot, then bar |
| Relationship | Chen | Reading |
|---|---|---|
| One-to-Many (1:M) | PAINTER 1 — paints — M PAINTING |
|
| Many-to-Many (M:N) | EMPLOYEE M — learns — N SKILL |
|
| One-to-One (1:1) | EMPLOYEE 1 — manages — 1 STORE |
|
- Slide 47 — CLASS is optional to COURSE: COURSE (1,1) — generates — (0,N) CLASS; the CLASS end shows a circle with a crow's foot.
The invoicing problem (slide 49, Chen and crow's foot ERDs): this model may be read as follows
- each CUSTOMER may generate one or more INVOICEs
- each INVOICE is generated by one CUSTOMER
- each INVOICE contains one or more invoice LINEs
- each invoice LINE is contained in one INVOICE
Entity sets to schemasالكيانات إلى جداول
Reduction to relation schemas
Reduction to relation schemas (slide 53)
- Entity sets and relationship sets can be expressed uniformly as relation schemas that represent the contents of the database.
- A database which conforms to an E-R diagram can be represented by a collection of schemas.
- For each entity set and relationship set there is a unique schema that is assigned the name of the corresponding entity set or relationship set.
- Each schema has a number of columns (generally corresponding to attributes), which have unique names.
| E-R constructالبنية في المخطط | Relation schemaالمخطط العلائقي |
|---|---|
| Strong entity set | Same attributes: student(ID, name, tot_cred) |
| Weak entity set | Includes the primary key of the identifying strong entity set: section(course_id, sec_id, sem, year) |
| Composite attribute |
|
| Multivalued attribute M of E | Separate schema EM with the key of E and M: inst_phone(ID, phone_number) |
- Ignoring multivalued attributes, the extended instructor schema is: instructor(ID, first_name, middle_initial, last_name, street_number, street_name, apt_number, city, state, zip_code, date_of_birth) (slide 56).
المسألة
Instructor 22222 has phone numbers 456-7890 and 123-4567. What tuples go into inst_phone(ID, phone_number)? (slide 57)
المعطيات
- inst_phone
- (ID, phone_number)
خطوات الحل
- Each value of the multivalued attribute maps to a separate tuple.
النتيجة
(22222, 456-7890) and (22222, 123-4567)
Relationship sets to schemasالعلاقات إلى جداول
Reduction to relation schemas
A schema with the primary keys of the two participating entity sets and any descriptive attributes — advisor = (s_id, i_id).
Placing the foreign key (slides 58–60)
- Many-to-one / one-to-many, total on the many-side: add to the "many" side an attribute holding the primary key of the "one" side — dept_name in instructor instead of a schema for inst_dept.
- One-to-one: either side can act as the "many" side.
- If participation is partial on the "many" side, the extra attribute could result in null values.
- The schema of the relationship linking a weak entity set to its identifying strong entity set is redundant (section already contains sec_course's attributes).
Non-binary relationshipsالعلاقات غير الثنائية
Non-binary relationship sets (slide 62)
- Most relationship sets are binary; there are occasions when it is more convenient to represent relationships as non-binary — an E-R diagram with a ternary relationship: proj_guide joins instructor, student and project.
Cardinality on a ternary relationship (slide 63)
- At most one arrow out of a ternary (or greater degree) relationship.
- An arrow from proj_guide to instructor: each student has at most one guide for a project.
- More than one arrow has two possible meanings, so we outlaw more than one arrow.
Binary vs non-binary (slide 79)
- An n-ary relationship shows more clearly that several entities participate in a single relationship.
- parents (child, father, mother) is best replaced by two binary relationships, father and mother — this allows partial information (e.g., only the mother known).
- Some relationships are naturally non-binary: proj_guide.
Converting R(A, B, C) to binary form (slide 80)
- 1
Replace R by an artificial entity set E and three relationship sets RA, RB, RC.
- 2
Create an identifying attribute for E and add any attributes of R to E.
- 3
For each (ai, bi, ci) in R: create entity ei, add (ei, ai) to RA, (ei, bi) to RB, (ei, ci) to RC.
Converting non-binary relationships (slide 81)
- Also need to translate constraints: translating all constraints may not be possible; there may be instances in the translated schema that cannot correspond to any instance of R.
- Exercise (slide): add constraints to the relationships RA, RB and RC to ensure that a newly created entity corresponds to exactly one entity in each of entity sets A, B and C.
- We can avoid creating an identifying attribute by making E a weak entity set identified by the three relationship sets.
| Degree | Example |
|---|---|
| Unary | EMPLOYEE manages EMPLOYEE |
| Binary | PROFESSOR teaches CLASS |
| Ternary (conceptual) | DOCTOR, PATIENT and DRUG joined by prescribes |
| Ternary (logical) |
|
Specialization and generalizationالتخصيص والتعميم
Specialization, generalization and their constraints
Specializationالتخصيص
- Top-down: designate sub-groupings within an entity set.
- Sub-groupings become lower-level entity sets with their own attributes or relationships.
Generalizationالتعميم
- Bottom-up: combine entity sets that share the same features into a higher-level entity set.
- Specialization and generalization are simple inversions of each other, drawn the same way.
- Depicted by a triangle labeled IS A (instructor "is a" person).
- Attribute inheritance: a lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set.
- Slide 66: overlapping — employee and student; disjoint — instructor and secretary.
person (ID, name, street, city)
employee (salary)
- Slide 66 also lists Partial (default) and Total.
- The terms specialization and generalization are used interchangeably (slide 71).
Completeness and disjointness constraintsالاكتمال والتداخل
Specialization, generalization and their constraints
Not every supertype occurrence is a member of a subtype — the default.
Every supertype occurrence must be a member of at least one subtype (keyword total with a dashed line). E.g., every student is graduate or undergraduate.
Each supertype instance appears in only one subtype; implemented with the value of a subtype discriminator attribute in the supertype.
An instance may appear in more than one subtype; implementation requires one discriminator attribute for each subtype.
Slides 69–70
- Partial generalization is the default.
- Total generalization is specified by adding the keyword total in the diagram and drawing a dashed line from the keyword to the corresponding hollow arrow-head (for a total generalization), or to the set of hollow arrow-heads (for an overlapping generalization).
- The student generalization is total: all student entities must be either graduate or undergraduate. Because the higher-level entity set arrived at through generalization is generally composed of only those entities in the lower-level entity sets, the completeness constraint for a generalized higher-level entity set is usually total.
- Disjoint subtypes are also known as nonoverlapping subtypes (d) (slide 70).
Specialization to schemasالتخصيص إلى جداول
Specialization, generalization and their constraints
Method 1الطريقة 1
- A schema for the higher-level entity, and for each lower-level entity set: the higher-level primary key + local attributes.
- person(ID, name, street, city); student(ID, tot_cred); employee(ID, salary).
- Drawback: information about an employee requires accessing two relations.
Method 2الطريقة 2
- A schema for each entity set with all local and inherited attributes.
- student(ID, name, street, city, tot_cred); employee(ID, name, street, city, salary).
- Drawback: name, street and city may be stored redundantly for people who are both students and employees.
Aggregationالتجميع
Record evaluations of a student by a guide on a project. eval_for and proj_guide represent overlapping information: every eval_for corresponds to a proj_guide relationship, but some proj_guide relationships may not have any eval_for, so proj_guide cannot be discarded.
Treat the relationship as an abstract entity, allowing relationships between relationships — it eliminates the redundancy.
- Slide 72: without aggregation, eval_for joins instructor, student, project and evaluation, beside proj_guide.
- Aggregation: treat relationship as an abstract entity; allows relationships between relationships; abstraction of relationship into new entity (slide 73).
- Slide 74: proj_guide with instructor, student and project is boxed as one unit, and eval_for joins that box to evaluation. It represents: a student is guided by a particular instructor on a particular project; a student, instructor, project combination may have an associated evaluation.
Schema (slide 75)
- Primary key of the aggregated relationship + primary key of the associated entity set + descriptive attributes.
- eval_for (s_ID, project_id, i_ID, evaluation_id); the schema proj_guide is redundant.
Design issues and UMLقضايا التصميم وUML
Design issues, decisions and UML
E-R design decisions (slide 82)
- The use of an attribute or entity set to represent an object.
- Whether a real-world concept is best expressed by an entity set or a relationship set.
- The use of a ternary relationship versus a pair of binary relationships.
- The use of a strong or weak entity set.
- The use of specialization/generalization — contributes to modularity in the design.
- The use of aggregation — can treat the aggregate entity set as a single unit without concern for the details of its internal structure.
- Entity vs. attribute: phone as an entity allows extra information about phone numbers, plus multiple numbers.
- Entity vs. relationship set: use a relationship set to describe an action that occurs between entities; e.g., date as an attribute of advisor or of student.
- Specialization/generalization contributes to modularity in the design.
- Aggregation treats the aggregate entity set as a single unit without concern for its internal structure.
The design-issue diagrams (slides 77–78)
- Slide 77: instructor (ID, name, salary, phone_number) versus instructor (ID, name, salary) — inst_phone — phone (phone_number, location).
- Slide 78: section — section_reg — registration — student_reg — student; the slide also names placement of relationship attributes.
UML (slides 87–88)
- UML: Unified Modeling Language, modelling an entire software system.
- UML class diagrams correspond to E-R diagrams, with differences — note the reversal of position in the cardinality constraint depiction.
| Concept | Chen-style (slide 85–86 left) | Crow's-foot style (slide 86 right) |
|---|---|---|
| Entity set E with simple A1 (primary key), composite A2 (A2.1, A2.2), multivalued A3, derived A4 | ovals around E: A1 underlined, A2 with its own ovals, A3 double oval, A4 dashed oval | لا تذكر الشرائح شيئًا هنا. |
| Weak entity set | double rectangle | لا تذكر الشرائح شيئًا هنا. |
| Generalization / total generalization | triangle ISA / triangle ISA with a double line | لا تذكر الشرائح شيئًا هنا. |
| Many-to-many | E1 * — R — * E2 | crow's feet at both ends |
| One-to-one | E1 1 — R — 1 E2 | plain line |
| Many-to-one | E1 * — R — 1 E2 | crow's foot at E1 |
| Participation in R: total (E1) and partial (E2) | double line at E1 |
|
| ER diagram notation | Equivalent in UML |
|---|---|
| Entity with attributes (simple, composite, multivalued, derived) | Class with simple attributes and methods (attribute prefixes: + = public, – = private, # = protected) |
| Binary relationship: E1 role1 — R — role2 E2 | E1 role1 — R — role2 E2 as a line |
| Relationship attributes: A1 attached to R | A box R with A1, joined to the line by a dotted line |
| Cardinality constraints: E1 0..* — R — 0..1 E2 | E1 0..1 — R — 0..* E2 (note the reversal of position) |
| n-ary relationships | drawn with the diamond R as in ER |
| Overlapping generalization | separate arrows with a dotted line labeled overlapping |
| Disjoint generalization | merged arrow labeled disjoint |
- Generalization can use merged or separate arrows independent of disjoint/overlapping (slide 89).
- UML has many components to graphically model different aspects of an entire software system (slide 87).
الخلاصة
أنهيت الدرس
الخطوة التالية: ثبّت المعلومات بالبطاقات، ثم اختبر نفسك بالأسئلة.
ما راجعته في هذا الدرس
- Design phases and database design stepsمراحل التصميم وخطوات بناء القاعدة
- Data models and the ER modelنماذج البيانات ونموذج الكيان والعلاقة
- Entity sets and relationship setsمجموعات الكيانات والعلاقات
- Mapping cardinality constraintsأنماط التعدد
- Kinds of attributesأنواع الصفات
- Existence dependence and weak entitiesالاعتماد في الوجود والكيانات الضعيفة
- ER diagrams: entities, relationships, roles and namingمخطط الكيان والعلاقة: الرموز والأدوار والتسمية
- Participation and minimum cardinalityالمشاركة والحد الأدنى للتعدد
- Reduction to relation schemasالتحويل إلى مخططات علاقات
- Non-binary relationshipsالعلاقات غير الثنائية
- Specialization, generalization and their constraintsالتخصيص والتعميم وقيودهما
- Aggregationالتجميع
- Design issues, decisions and UMLقضايا التصميم وقراراته وUML