Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 37

Chapter – 3 (Data Modeling Using the Entity-Relationship (ER)

Model)
)‫ (نمذجة البيانات باستخدام نموذج العالقة بين الكيان‬3 ‫الفصل‬
Entity relationship model:-
An entity relationship model, also called an entity-relationship (ER) diagram,
is a graphical representation of entities and their relationships to each other,
typically used in computing in regard to the organization of data within databases
or information systems.

‫نموذج عالقة الكيان‬:

‫ هو تمثيل بياني للكيانات وعالقاتها‬،‫ الذي يطلق عليه أيضا رسم تخطيطي للكيان‬،‫كما أن نموذج عالقة الكيان‬
‫ وتستخدم عادة في الحوسبة فيما يتعلق بتنظيم البيانات داخل قواعد البيانات أو نظم‬،‫ببعضها البعض‬
‫المعلومات‬.

Role of high-Level data model in Database Design process


Creating conceptual schema for the database, using a high-level conceptual data
model is called conceptual design

‫دور نموذج البيانات عالي المستوى في عملية تصميم قاعدة البيانات‬

‫ باستخدام نموذج بيانات مفاهيمية رفيعة المستوى يسمى التصميم‬،‫إنشاء مخطط مفاهيمي لقاعدة البيانات‬
‫المفاهيمي‬
conceptual schema:-
The conceptual schema is a concise description of the data requirements of the
users and includes detailed descriptions of the entity types, relationships, and
constraints; these are expressed using the concepts provided by the high-level data
model.
‫المخطط المفاهيمي‬: -
‫المخطط المفاهيمي هو وصف موجز لمتطلبات البيانات للمستخدمين ويتضمن وصفا تفصيليا ألنواع الكيانات‬
‫‪.‬والعالقات والقيود‪ .‬يتم التعبير عن ذلك باستخدام المفاهيم التي يوفرها نموذج البيانات رفيع المستوى‪.‬‬

‫‪Entity:-‬‬
‫‪Real world object or thing that is independent existence. An entity may be an‬‬
‫‪object with a physical existence (for example, a particular person, car, house, or‬‬
‫‪employee) or it may be an object with a conceptual existence (for example, a‬‬
‫‪company, a job, or a university course, Bank).‬‬
‫‪: -‬كيان‬

‫العالم الحقيقي الكائن أو الشيء الذي هو وجود مستقل‪ .‬قد يكون الكيان كائن له وجود مادي (على سبيل‬
‫المثال‪ ،‬شخص معين أو سيارة أو منزل أو موظف) أو قد يكون موضوعا له وجود مفاهيمي (على سبيل‬
‫‪).‬المثال شركة أو وظيفة أو دورة جامعية‪ ،‬بنك‬

‫‪Attributes:-‬‬
‫‪Properties that Describes the entity‬‬

‫‪Example:‬‬

‫‪Entity – Employee‬‬

‫…‪Attributes – Empno, Empname, Age, Salary etc‬‬

‫‪An entity has value for their attributes‬‬

‫‪Example:-‬‬

‫‪ : -‬الصفات‪Empno=1001, Empname=’smith’, age=30, salary=6000‬‬

‫الخصائص التي تصف الكيان‬

‫‪:‬مثال‬

‫كيان ‪ -‬موظف‬

‫‪ ...‬سمات ‪ -‬إمبنو‪ ،‬إمبنام‪ ،‬إيدج‪ ،‬ساالري إتك‬


‫تمتلك المنشأة قيمة لخصائصها‬

‫مثال‬:-

6000 = ‫ ساالري‬،30 = ‫ إيدج‬،'‫ إمبنام = 'سميث‬،1001 = ‫إمبنو‬

Types of attributes:-
1. Single valued attribute
Attribute which has single value for its attribute
Example : empno=1001, age=30

2. Composite attributes / Compound attributes


Compose of several components. Composites attributes are divided into
smaller subparts which represent more basic attributes.
Example:-
Employee Address : street address, city, state, country, zip code

Composite attribute forms a hierarchy, they are denoted in between brackets


( )
EmpAddress (street address(streetno, street-name,apartment-no), city, state,
country, zip code)
‫أنواع السمات‬: -
‫سمة قيمة واحدة‬-1
‫السمة التي لها قيمة واحدة للسمة الخاصة بها‬
30 = ‫ العمر‬،1001 = ‫ إمبنو‬:‫مثال‬

‫ سمات مجمع‬/ ‫السمات المركبة‬-2


‫ تنقسم سمات المركبة إلى أجزاء فرعية أصغر تمثل سمات أساسية أكثر‬.‫تتألف من عدة مكونات‬.
‫مثال‬:-
‫ الرمز البريدي‬،‫ البلد‬،‫ الوالية‬،‫ المدينة‬،‫ عنوان الشارع‬:‫عنوان الموظف‬
‫)( تشكل السمة المركبة تسلسل هرمي‪ ،‬يشار إليها بين قوسين‬
‫)إمبادريس (عنوان الشارع (ستريتنو‪ ،‬اسم الشارع‪ ،‬شقة‪-‬ال)‪ ،‬المدينة‪ ،‬الوالية‪ ،‬البلد‪ ،‬الرمز البريدي‬

‫‪Example :‬‬

‫‪3. Simple Attributes/Atomic Attributes : The attributes which cannot be‬‬


‫‪divided into smaller subparts are called simple or atomic attributes. For‬‬
‫‪example, age of employee entity‬‬
‫‪4. Multi valued attribute‬‬
‫‪More than one value at a time for an attribute and they are denoted in‬‬
‫} { ‪between brackets‬‬
‫‪ -3‬سمات بسيطة ‪ /‬سمات الذرية‪ :‬السمات التي ال يمكن تقسيمها إلى أجزاء فرعية أصغر تسمى‬
‫سمات بسيطة أو ذرية‪ .‬على سبيل المثال‪ ،‬سن الكيان الموظف‬
‫‪-4‬سمة متعددة القيمة‬
‫}{ أكثر من قيمة واحدة في كل مرة لخاصية مميزة‪ ،‬ويتم اإلشارة إليها بين قوسين‬

‫‪Examples:‬‬
5. Stored and derived attributes
Two or more attribute values are related to each other
Example: Age and date-of-birth,
age is calculated by current value and date of birth
Age is derived from date-of-birth, and date-of-birth value stored in the
database.

6. Null value attribute/ Optional attribute:


An optional attribute may not have a value in it and can be left blank. For
example, In a STUDENT entity, Middle-name or email address is an
optional attribute, as some students may not have middle-name or email
address.
7. Complex attributes
If a attribute of an entity is built using composite and multi valued attributes
then it is called complex attribute
Example:
{Address-Phone({Phone(area-code,phone-no)},Address(street-
address(street-no,street-name),city,state,country,zip-code)}

8. Key Attribute : represents primary key. (main characteristics of an entity).


It is an attribute, that has distinct value for each entity/element in an entity
set. For example, StudentID in a Student Entity Type, EmployeeID In a
Employee entity type .
9. Non Key Attributes : These are attributes other than candidate key
attributes in a table. For example First-name is a non key attribute as it does
not represent the main characteristics of the entity.
10.Required Attribute : A required attribute is an attribute that must have a
data value. These attributes are required because they describe what is
‫‪important in the entity. For example, In a STUDENT entity, first-name and‬‬
‫‪last-name is a required attribute.‬‬

‫المخزنة والمستمدة سمات‪5-‬‬

‫يرتبط سمتان أو أكثر من قيم السمات ببعضها البعض‬

‫مثال‪ :‬العمر وتاريخ الميالد‪،‬‬

‫يتم احتساب العمر حسب القيمة الحالية وتاريخ الميالد‬

‫‪.‬العمر مشتق من تاريخ الميالد‪ ،‬وقيمة تاريخ الميالد المخزنة في قاعدة البيانات‬

‫‪:‬سمة قيمة فارغة ‪ /‬سمة اختيارية‪6-‬‬

‫قد ال يكون لخاصية اختيارية قيمة فيها ويمكن تركها فارغة‪ .‬على سبيل المثال‪ ،‬في كيان الطالب‪،‬‬
‫يكون االسم األوسط أو عنوان البريد اإللكتروني سمة اختيارية‪ ،‬حيث قد ال يكون لدى بعض الطالب‬
‫‪.‬اسم متوسط أو عنوان بريد إلكتروني‬

‫سمات معقدة ‪7-‬‬

‫إذا تم إنشاء سمة من كيان باستخدام سمات مركبة ومتعددة القيمة ثم يطلق عليه السمة المعقدة‬

‫‪:‬مثال‬

‫عنوان الهاتف ({الهاتف (منطقة رمز‪ ،‬هاتف ال)}‪ ،‬عنوان (شارع عنوان (الشارع ال‪ ،‬شارع {‬
‫})االسم)‪ ،‬المدينة‪ ،‬الدولة‪ ،‬الدولة‪ ،‬والرمز البريدي رمز‬

‫السمة الرئيسية‪ :‬يمثل المفتاح األساسي‪( .‬الخصائص الرئيسية للمنشأة)‪ .‬وهي سمة‪ ،‬لها قيمة مميزة ‪8-‬‬
‫لكل كيان ‪ /‬عنصر في مجموعة الكيان‪ .‬على سبيل المثال‪ ،‬ستودنتيد في نوع كيان الطالب‪ ،‬إمبلوييد‬
‫‪.‬في نوع كيان موظف‬

‫سمات غير الرئيسية‪ :‬هذه سمات غير سمات مفتاح المرشح في جدول‪ .‬على سبيل المثال االسم ‪9-‬‬
‫‪.‬األول هو سمة غير مفتاح ألنها ال تمثل الخصائص الرئيسية للكيان‬

‫السمة المطلوبة‪ :‬السمة المطلوبة هي سمة يجب أن يكون لها قيمة بيانات‪ .‬هذه الصفات مطلوبة ‪10-‬‬
‫ألنها تصف ما هو مهم في الكيان‪ .‬على سبيل المثال‪ ،‬في كيان الطالب‪ ،‬يكون االسم األول واسم‬
‫‪.‬العائلة سمة مطلوبة‬
Entity types:

is defined as a collection of entities that have the same attributes. For example,
employee in a company database. As same attributes are shared by the employee
entities, but such entity has its own value for each attributes.

‫أنواع الكيانات‬:

‫ موظف في قاعدة‬،‫ على سبيل المثال‬.‫يتم تعريفها على أنها مجموعة من الكيانات التي لها نفس السمات‬
‫ ولكن هذا الكيان له قيمته الخاصة لكل‬،‫ كما يتم تقاسم نفس السمات من قبل الكيانات الموظف‬.‫بيانات الشركة‬
‫سمات‬..

Entity sets:

Collection of similar entities of same type that share the same attribute at any point
in time. For example, a Faculty set may contain all the teachers of a college, Set of
all persons, Set of Companies etc. The Entity set is also called extension of the
Entity Type.

‫الكيان يحدد‬:

‫ على‬.‫مجموعة من الكيانات المماثلة من نفس النوع التي تشترك في نفس السمة في أي وقت من األوقات‬
‫ مجموعة من‬،‫ مجموعة من جميع األشخاص‬،‫ قد تحتوي مجموعة كلية على جميع معلمي الكلية‬،‫سبيل المثال‬
‫ ويسمى أيضا مجموعة الكيان تمديد لنوع الكيان‬.‫الشركات الخ‬
Key attributes:

Entity type has one or more attributes whose value is distinct for each individual
entity in the entity set.

‫الصفات الرئيسية‬:

‫يحتوي نوع الكيان على سمة واحدة أو أكثر تكون قيمتها مميزة لكل كيان على حدة في مجموعة الكيان‬.

If attribute is simple or single value then simple key, if attribute is composite then
key is composite key

‫ إذا السمة هو مركب ثم المفتاح هو مفتاح مركب‬،‫إذا السمة هي بسيطة أو قيمة واحدة ثم مفتاح بسيط‬

Value set or domain of attributes:

Each simple attribute of an entity type is associated with a value set (or domain of
values), which specifies the set of values that may be assigned to that attribute for
each individual entity. Value sets are specified using the Data types such as -
integer, string, Boolean, float, enumerated type subrange, date, time etc….
‫مجموعة القيم أو نطاق السمات‬:
‫ترتبط كل سمة بسيطة لنوع الكيان بمجموعة قيمة (أو مجال قيم)‪ ،‬تحدد مجموعة القيم التي قد يتم تعيينها لهذه‬
‫السمة لكل كيان على حدة‪ .‬يتم تحديد مجموعات القيمة باستخدام أنواع البيانات مثل ‪ -‬عدد صحيح‪ ،‬سلسلة‪،‬‬
‫منطقية‪ ،‬تعويم‪ ،‬تعداد نوع فرعي‪ ،‬التاريخ‪ ،‬الوقت الخ‪...‬‬
‫‪Relationship:‬‬

‫‪Relates two or more entities with a specific meaning‬‬

‫‪Example: employee works-for department‬‬

‫صلة‬

‫يربط كيانين أو أكثر مع معنى محدد‬

‫مثال‪ :‬موظف يعمل في القسم‬

‫‪Degree of a relationship‬‬

‫‪The degree of relationship is number of participants entity in the relation.‬‬

‫‪in th above example degree is two i.e binary‬‬

‫)‪Ternary relationship (degree of relationship is 3‬‬

‫درجة العالقة‬

‫‪.‬ودرجة العالقة هي عدد الكيانات المشاركة في العالقة‬


‫في المثال أعاله درجة اثنين هما ثنائي‬

)3 ‫العالقة الثالثية (درجة العالقة‬

Relationships sets: is a set of relationships of the same type.

Relationship set R is a subset of –


‫ هي مجموعة من العالقات من نفس النوع‬:‫مجموعات العالقات‬.
‫ مجموعة العالقة‬R ‫ هي مجموعة فرعية من‬-

{(r1,r2,r3,....rn)| r1 ∈ E1, r2 ∈ E2, rn ∈ En}

where r1,r2,….rn are called relationships and E1,E2,….En are entity sets.
‫ حيث‬r1 ،r2 ،... .rn ‫ تسمى العالقات و‬E1 ،E2 ،... ‫إن هي مجموعات الكيانات‬.

relation type: The way in which two or more entity types are related is
called relation type.

.‫ الطريقة التي يتم فيها ربط نوعين أو أكثر من الكيانات يسمى نوع العالقة‬:‫نوع العالقة‬

Exercise 1: identify the entities and relationship between these entities in the
following questions.

Q1. An employee works in a department.


Answer:

Entities : Employee , Department

Relationship : Works in

Q2. An Employee has three children

Answer:

Entities : Employee , Children

Relationship : Has

Q3: Some teachers are assigned a course

Answer:

Entities : Teacher , Course

Relationship : is assigned.

Q4: A student studies English, Mathematics, Computer, Physics.

Answer:

Entities : Student , Subject

Relationship : Studies

Q5: A company sells 10 products, Customers can order products by phone.

Answer:

Entities : Customer , Product

Relationship : Orders

Q6: An even in the sports day of a college will cancelled if there are no
participants.

Answer:

Entities : Student , Event


Relationship : Participates

Q7: A teacher calculates the total marks of each student. The marks are recorded in
the system as grade report which are displayed to the students.

Answer:

Entities : Student , Grade_Report

Relationship : Has

Q8: All the students in the University must study some courses.

Answer:

Entities : Student , Course

Relationship : Studies

‫ تحديد الكيانات والعالقة بين هذه الكيانات في األسئلة التالية‬:1 ‫التمرين‬.

Q1. ‫يعمل موظف في قسم‬.

‫إجابة‬:

‫ إدارة‬،‫ موظف‬:‫الكيانات‬

‫ يعمل في‬:‫العالقة‬

Q2. ‫موظف لديه ثالثة أطفال‬

‫إجابة‬:

‫ أطفال‬،‫ موظف‬:‫الكيانات‬

‫ هل‬:‫العالقة‬

‫ يتم تعيين بعض المعلمين دورة‬:3 ‫س‬

‫إجابة‬:

‫ الدورة‬،‫ المعلم‬:‫الكيانات‬

‫ يتم تعيين‬:‫العالقة‬.
‫‪.‬طالب دراسات اللغة اإلنجليزية والرياضيات والحاسوب والفيزياء ‪Q4:‬‬

‫‪:‬إجابة‬

‫الكيانات‪ :‬الطالب‪ ،‬الموضوع‬

‫العالقة‪ :‬الدراسات‬

‫‪.‬شركة تبيع ‪ 10‬المنتجات‪ ،‬يمكن للعمالء طلب المنتجات عن طريق الهاتف ‪q5:‬‬

‫‪:‬إجابة‬

‫الكيانات‪ :‬العميل‪ ،‬المنتج‬

‫العالقة‪ :‬األوامر‬

‫‪.‬حتى في اليوم الرياضي من كلية إلغاء إذا لم يكن هناك أي مشاركين ‪Q6:‬‬

‫‪:‬إجابة‬

‫الكيانات‪ :‬الطالب‪ ،‬الحدث‬

‫العالقة‪ :‬يشارك‬

‫س ‪ :7‬يحسب المعلم مجموع عالمات کل طالب‪ .‬يتم تسجيل العالمات في النظام كما تقرير الصف التي يتم‬
‫‪.‬عرضها للطالب‬

‫‪:‬إجابة‬

‫‪Grade_Report‬الكيانات‪ :‬طالب‪،‬‬

‫العالقة‪ :‬هل‬

‫‪.‬يجب على جميع الطالب في الجامعة دراسة بعض الدورات ‪Q8:‬‬

‫‪:‬إجابة‬

‫الكيانات‪ :‬طالب‪ ،‬دورة‬

‫العالقة‪ :‬الدراسات‬
Constraints on relationship:

Also called ratio constraints (or) maximum cardinality

Cardinality expresses the number of entities to which another entity can be


associated via a relationship set (or) It specifies the number of relationship
instances that an entity can participate in a relation set.

There are 4 types of Cardinality Ratios :


 One-to-One Cardinality (1:1)
 One-to-Many Cardinality (1:N)
 Many-to-One Cardinality (N:1)
 Many-to-Many Cardinality (M:N)
Notations of Different Types of Cardinality In ER Diagram –
‫القيود على العالقة‬:
‫وتسمى أيضا قيود نسبة (أو) الحد األقصى كارديناليتي‬
‫تعبر كارديناليتي عن عدد الكيانات التي يمكن أن يرتبط بها كيان آخر عبر مجموعة عالقة (أو) يحدد عدد‬
‫حاالت العالقة التي يمكن للكيان المشاركة فيها في مجموعة عالقة‬.

‫ أنواع من النسب كارديناليتي‬4 ‫هناك‬:


• 1 :1( ‫)واحد إلى واحد كارديناليتي‬
• 1( ‫واحد إلى العديد من كارديناليتي‬: N)
• ‫( كارديناليتي متعددة إلى واحد‬N: 1)
• ‫( العديد من الكارديناليتي‬M: N)
‫ مالحظات من أنواع مختلفة من كارديناليتي في مخطط إير‬-
One-to-One Cardinality (1:1) –
An entity in set A is associated with atmost one entity in B, and an entity in B is
associated with atmost one entity in A. This type of cardinality is referred as one to
one Cardinality.
For example, an Employee as a Manager manages only one Department and the
vice versa is also true as a department have only one Manager
1 :1( ‫ )واحد إلى واحد كارديناليتي‬-
‫ ويرتبط كيان في المجموعة‬A ‫ بكيان واحد في‬B‫ ويرتبط كيان في‬، B ‫ بوحدة واحدة تقريبا في‬A. ‫ويشار إلى‬
‫هذا النوع من العناصر األساسية كواحدة إلى كارديناليتي‬.
‫ الموظف كمدير يدير قسم واحد فقط والعكس بالعكس صحيح أيضا كما قسم لديها مدير‬،‫على سبيل المثال‬
‫واحد فقط‬
One to Many Cardinality (1:M) –
An entity in A is associated with any number (0 or more) with an entity B, but a
entity in B, however can be associated with at most one entity in A. For example,
An employee as a Manager can manage more than one Department, One
department has many employees

Many to One Cardinality (M:1) –

An entity in A is associated with at most one entity in B. An entity in B, however,


can be associated with any number (0 or more) of entities in A. For example, An
Employee can work only for one Department, But each Department can have 0 or
more employees, Many employees works-for one department

Many to Many Cardinality (M:N) –


An entity in A is associated with any number (0 or more) of entities in B, and an
entity in B is associated with any number( 0 or more) of entities in A. For example,
An Employee can works on several Projects and a Project may have several
Employees.
Many employees works-on many projects
1( ‫واحد إلى العديد من كارديناليتي‬: M) -
‫ ويرتبط أي كيان في‬A ‫ أو أكثر) مع كيان‬0( ‫ بأي رقم‬B‫ ولكن كيان في‬، B ‫ ومع ذلك يمكن أن‬،
‫ يكون مرتبطا بمعظم كيان واحد في‬A. ‫ يمكن للموظف كمدير إدارة أكثر من واحد‬،‫على سبيل المثال‬
‫ قسم واحد لديه العديد من الموظفين‬،‫قسم‬
‫( العديد إلى واحد كارديناليتي‬M: 1) -
‫ كيان في‬A ‫ مرتبط بكيان واحد على األكثر في‬B. ‫ يمكن أن يرتبط الكيان في‬B ‫ أو‬0( ‫بأي عدد‬
‫ أكثر) من الكيانات في‬A. ‫ ولكن كل‬،‫ يمكن أن يعمل الموظف فقط إلدارة واحدة‬،‫على سبيل المثال‬
‫ لقسم واحد‬- ‫ ويعمل العديد من الموظفين‬،‫ أو أكثر من الموظفين‬0 ‫قسم يمكن أن يكون‬
‫( العديد من كارديناليتي‬M: N) -
‫ ويرتبط الكيان في‬A ‫ أو أكثر) من الكيانات في‬0( ‫ بأي عدد‬B‫ ويرتبط كيان في‬، B ‫ أو‬0( ‫بأي عدد‬
‫ أكثر) من الكيانات في‬A. ‫ يمكن أن يعمل الموظف على عدة مشاريع و قد يكون‬،‫على سبيل المثال‬
‫للمشروع عدة موظفين‬.
.‫العديد من الموظفين يعمل على العديد من المشاريع‬
Exercise 2: write the cardinality ratio for the following

‫ اكتب النسبة األساسية لما يلي‬:2 ‫التمرين‬

Entity 1 Cardinality Ratio Entity 2

1. STUDENT 1:1 SOCIAL_SECURITY_CARD


2. STUDENT M:1 TEACHER
3. CLASSROOM 1:M WALL
4. COURSE 1:M TEXTBOOK
5. ITEM M:1 ORDER

Role names:

A relationship type has a name which signifies what role a participating entity
plays in that relationship instance. The role names helps to explain what
the relationship means. In the above example WORKS_FOR relationship type,
employee plays the role of worker and department plays the role of
employee(because a department consists of a number of employees.

‫أسماء األدوار‬:

‫ وتساعد أسماء األدوار في‬.‫نوع العالقة له اسم يشير إلى الدور الذي يلعبه الكيان المشارك في مثيل العالقة‬
‫ في المثال أعاله نوع العالقة‬.‫ شرح ما تعنيه العالقة‬WORKS_FOR ‫ موظف يلعب دور عامل وقسم‬،
‫يلعب دور الموظف (ألن قسم يتكون من عدد من الموظفين‬.

Recursive relationship:

If the same entity type participate more than once in a relationship type in
different roles then such relationship types are called recursive relationship. For
example, in the below figure REPORTS_TO is a recursive relationship as the
Employee entity type plays two roles – 1) Supervisor and 2) Subordinate.

‫العالقة العودية‬:

‫إذا كان نفس نوع الكيان يشارك أكثر من مرة في نوع العالقة في أدوار مختلفة ثم تسمى هذه األنواع العالقة‬
‫ في الشكل التالي‬،‫ على سبيل المثال‬.‫ عالقة عودية‬REPORTS_TO ‫هو عالقة متكررة كما يلعب نوع كيان‬
‫) ثانوي‬2 ‫) المشرف و‬1 - ‫الموظف دورين‬
Another way of representing recursive relationship is as follows

If ‘1’ represents employee in the supervisor role and ‘2’---- means employee in the subordinate
role

In the above example for relation r1, e1 is subordinate and e5 is a supervisor


For relation r2, e2 is subordinate and e1 is a supervisor

For relation r3, e3 is subordinate and e1 is a supervisor. So on.

Attributes of relationship types:-

Relationships types can have attributes similar to entity

Example:
For example, to record the number of hours per week that an employee works on a
particular project, we can include an attribute Hours for the WORKS_ON
relationship
Another example is to include the date on which a manager started managing a
department via an attribute Start_date for the MANAGES relationship type

Partial/Optional Participation-

Participation is said to be partial if only some entities in E participate in


relationships in R (or) some entities in entity set are depend on some another
entities in entity set. For example, It is not necessary that all employees manage
some department Because all employees may not be the Manager . So the
participation of “EMPLOYEE” entity in the “MANAGES” relationship type is
partial.

‫ سمات أنواع العالقة‬: -

‫يمكن أن تكون لعالقات العالقات سمات مشابهة للكيان‬

‫مثال‬:
‫على سبيل المثال‪ ،‬لتسجيل عدد الساعات في األسبوع الذي يعمل فيه موظف في مشروع معين‪ ،‬يمكننا‬
‫‪ WORKS_ON‬تضمين سمة ساعات لعالقة‬

‫لنوع العالقة ماناجيس ‪_date‬مثال آخر هو تضمين التاريخ الذي بدأ مدير إدارة إدارة عبر سمة بدء‬

‫‪ -‬المشاركة الجزئية ‪ /‬االختيارية‬

‫أو) بعض الكيانات ( ‪ R‬المشاركة في العالقات في ‪ E‬ويقال إن المشاركة جزئية إذا كانت بعض الكيانات في‬
‫في مجموعة الكيانات تعتمد فقط على بعض الكيانات األخرى في مجموعة الكيان‪ .‬على سبيل المثال‪ ،‬ليس من‬
‫الضروري أن جميع الموظفين إدارة بعض اإلدارات ألن جميع الموظفين قد ال يكون المدير‪ .‬لذا فإن مشاركة‬
‫‪.‬كيان "إمبلويي" في نوع العالقة "ماناجيس" جزئية‬

‫‪Structural constraints:‬‬

‫‪Structural constraints on relationships, which replaces the cardinality ratio (1:1,‬‬


‫)‪1:N, M:N‬‬
‫‪and single/double line notation for participation constraints. This notation involves‬‬
‫‪associating a pair of integer numbers (min, max) with each participation of an‬‬
‫‪entity type E in a relationship type R, where‬‬ ‫‪0 ≤min ≤max and max ≥1. The‬‬
numbers mean that for each entity e in E, e must participate in at least min and at
most max relationship instances in R at any point in time. In this method, min = 0
implies partial participation, whereas min > 0 implies total participation.

Examples:

l A department has exactly one manager and an employee can manage at most
one department.

– Specify (0,1) for participation of EMPLOYEE in MANAGES

– Specify (1,1) for participation of DEPARTMENT in MANAGES

2 An employee can work for exactly one department but a department can
have any number of employees.

– Specify (1,1) for participation of EMPLOYEE in WORKS_FOR

– Specify (0,n) for participation of DEPARTMENT in WORKS_FOR

WeakEntity

Entity types that do not have key attributes of their own are called weak entity
types. A weak entity type always has a total participation constraint

Strong Entity
Entity types that do have a key attribute are called strong entity types.

Owner entity type


Entities belonging to a weak entity type are identified by being related to specific
entities from another entity type in combination with one of their attribute values.
We call this other entity type the identifying or owner entity type and we call the
‫‪relationship type that relates a weak entity type to its owner the identifying‬‬
‫‪relationship of the weak entity type.‬‬

‫‪:‬أمثلة‬
‫‪.‬ل قسم لديه بالضبط مدير واحد ويمكن للموظف إدارة على األكثر قسم واحد‬
‫تحديد (‪ )0،1‬لمشاركة الموظف في مانيجيس ‪-‬‬
‫تحديد (‪ )1،1‬لمشاركة اإلدارة في اإلدارة ‪-‬‬
‫‪.‬يمكن للموظف أن يعمل في قسم واحد فقط ولكن يمكن أن يكون للقسم أي عدد من الموظفين ‪2‬‬
‫‪ WorkS_FOR‬تحديد (‪ )1،1‬لمشاركة الموظف في ‪-‬‬
‫‪ WorkS_FOR‬تحديد (‪ ،0‬ن) لمشاركة اإلدارة في ‪-‬‬

‫كيان ضعيف‬
‫تسمى أنواع الكيانات التي ليس لها سمات رئيسية خاصة بها أنواع الكيانات الضعيفة‪ .‬إن نوع الكيان الضعيف‬
‫يواجه دوما قيودا إجمالية علی المشارکة‬

‫كيان قوي‬
‫‪.‬أنواع الكيانات التي لها سمة مفتاح تسمى أنواع الكيانات القوية‬

‫نوع كيان المالك‬


‫يتم تحديد الكيانات التي تنتمي إلى نوع كيان ضعيف من خالل ارتباطها بكيانات محددة من نوع آخر من‬
‫الكيانات باالقتران مع إحدى قيم السمات الخاصة بها‪ .‬ونحن نسمي هذا الكيان اآلخر نوع نوع أو نوع الكيان‬
‫‪.‬المالك ونطلق على نوع العالقة التي تتعلق نوع الكيان الضعيف لصاحبها عالقة تحديد نوع الكيان الضعيف‬
Examples :- Construct a preliminary design of the following

1. An entity type DEPARTMENT with attributes Name, Number,


Locations,Manager, and Manager_start_date. Locations is the only
multivalued attribute. We can specify that both Name and Number are
(separate) key attributes because each was specified to be unique.
‫ إنشاء تصميم أولي لما يلي‬- :‫أمثلة‬

1. ‫ نوع الكيان القسم مع سمات االسم والرقم والمواقع والمدير و‬Manager_start_date. ‫المواقع‬
‫ يمكننا تحديد أن كال من االسم والرقم هما سمات مفتاح (منفصلة) ألن‬.‫هي السمة متعددة القيم فقط‬
‫كل منهما تم تحديده ليكون فريدا‬

2. An entity type PROJECT with attributes Name, Number, Location, and


Controlling_department. Both Name and Number are (separate) key
attributes.

2. ‫ و‬،‫ الموقع‬،‫ الرقم‬،‫ نوع المشروع بروجيكت مع السمات االسم‬Controlling_department.


‫)كل من االسم والرقم سمات مفتاح (منفصلة‬.
3. An entity type EMPLOYEE with attributes Name, Ssn, Sex, Address,
Salary, Birth_date, Department, and Supervisor. Both Name and Address
may be composite attributes, individual components of Name—are
First_name, Middle_initial, Last_name and of Address are street no, street
name, city, state, country, zipcode.
3. ،‫ قسم‬،‫ الميالد_الوقت‬،‫ الراتب‬،‫ العنوان‬،‫ الجنس‬،‫ سن‬،‫نوع الكيان إمبلويي مع سمات االسم‬
‫ والمكونات الفردية لالسم هي فيرست نيم‬،‫ قد يكون كل من االسم والعنوان سمات مركبة‬.‫والمشرف‬
‫ و‬Middle_initial ‫ و‬Last_name ‫والعنوان هي الشارع نو واسم الشارع والمدينة والوالية والبلد‬
‫والرمز البريدي‬.

4. An entity type DEPENDENT with attributes Employee, Dependent_name, Sex,


Birth_date, and Relationship (to the employee).
،‫نوع الكيان ديبندنت مع سمات الموظف‬Dependent_name،‫ الجنس‬،
‫ والعالقة (للموظف‬،‫)تاريخ الميالد‬.

Examples:
Entity : CAR
Registration (Number, State), Vehicle_id, Make, Model, Year, {Color}
‫أمثلة‬:
‫ سيارة‬:‫الكيان‬
‫ دولة‬،‫ )تسجيل (عدد‬،Vehicle_id ،‫ السنة‬،‫ نموذج‬،‫ جعل‬،{‫}اللون‬

Example : A university registrar’s office maintains data about the following


entities:
1. courses, including number, title, credits, syllabus, and prerequisites;
2. course offerings, including course number, year, semester, section number,
instructor(s), timings, and classroom;
3. students, including student-id, name, and program;
4. instructors, including identification number, name, department, and title.
Further, the enrollment of students in courses and grades awarded to students in
each course they are enrolled for must be appropriately modeled. Construct an E-R
diagram for the registrar’s office. Document all assumptions that you make about
the mapping constraints.
‫ يحتفظ مكتب أمين السجل الجامعي ببيانات عن الكيانات التالية‬:‫مثال‬:
1. ‫ والشروط المسبقة‬،‫ المنهج‬،‫ واالئتمانات‬،‫ والعنوان‬،‫ بما في ذلك عدد‬،‫الدورات‬.
2. ،‫ توقيت‬،)‫ مدرب (ق‬،‫ رقم القسم‬،‫ الفصل الدراسي‬،‫ السنة‬،‫ بما في ذلك عدد بالطبع‬،‫بالطبع الدورات‬
‫والفصول الدراسية‬.
3. ‫ والبرنامج‬،‫ اسم‬،‫ بما في ذلك الطالب معرف‬،‫الطالب‬.
4. ‫ والعنوان‬،‫ اإلدارة‬،‫ االسم‬،‫ بما في ذلك رقم الهوية‬،‫المدربون‬.
‫ يجب أن يكون تسجيل الطالب في الدورات والدرجات الممنوحة للطالب في كل دورة هم‬،‫وعالوة على ذلك‬
‫ إنشاء مخطط‬.‫ المسجلين على غرار بشكل مناسب‬E-R ‫ قم بتوثيق جميع االفتراضات التي‬.‫لمكتب المسجل‬
‫تقوم بها حول قيود التعيين‬.
Example :

Students (name, gender, course) do projects(title). Each project has two supervisors
(name, gender, department). All students do a project but not all projects get taken.
More than one student can do the same project. Students meet one of their
supervisors regular and these meetings are recorded (date, time, student,
supervisor, notes).
‫مثال‬:

.)‫ اإلدارة‬،‫ النوع‬،‫ لكل مشروع مشرفان (االسم‬.)‫ بالطبع) القيام المشاريع (العنوان‬،‫ الجنس‬،‫الطالب (االسم‬
‫ أكثر من طالب واحد يمكن أن تفعل‬.‫جميع الطالب القيام بمشروع ولكن ليس كل المشاريع الحصول عليها‬
،‫ الوقت‬،‫ يلتقي الطالب أحد المشرفين عليهم بشکل منتظم وتسجل هذه االجتماعات (التاريخ‬.‫نفس المشروع‬
‫ المالحظات‬،‫ المشرف‬،‫)الطالب‬.
Example:

Construct an E-R diagram for a hospital with a set of patients and


a set of medical doctors. Associate with each patient a log of the
various tests and examinations conducted.
‫مثال‬:

‫ إنشاء مخطط‬E-R ‫ مشارك مع كل مريض‬.‫للمستشفى مع مجموعة من المرضى ومجموعة من األطباء‬


‫سجل لمختلف االختبارات واالمتحانات التي أجريت‬.
Example:
Construct an E-R diagram for a car-insurance company whose
customers own one or more cars each. Each car has associated
with it zero to any number of recorded accidents.

‫مثال‬:
‫ إنشاء مخطط‬E-R ‫ وقد‬.‫لشركة التأمين على السيارات التي يمتلك عمالؤها سيارة واحدة أو أكثر لكل سيارة‬
‫ارتبطت كل سيارة معها صفر إلى أي عدد من الحوادث المسجلة‬.
Example:

Draw the E-R diagram which models an online bookstore.


‫مثال‬:

‫ ارسم الرسم البياني‬E-R ‫الذي يعد مكتبة على اإلنترنت‬.

Example:
Consider a university database for the scheduling of classrooms for -final
exams. This database could be modeled as the single entity set exam, with
attributes course-name, section-number, room-number, and time. Alternatively,
one or more additional entity sets could be defined, along with relationship sets to
replace some of the attributes of the exam entity set, as
 course with attributes name, department, and c-number
 section with attributes s-number and enrollment, and dependent as a
weak entity set on course
 room with attributes r-number, capacity, and building
Show an E-R diagram illustrating the use of all three additional entity sets listed.
‫مثال‬:

‫ يمكن أن تكون هذه قاعدة‬.‫النظر في قاعدة بيانات الجامعة لجدولة الفصول الدراسية لالمتحانات النهائية‬
.‫ والوقت‬،‫ رقم الغرفة‬،‫ رقم القسم‬،‫ مع سمات بالطبع اسم‬،‫البيانات على غرار امتحان مجموعة الكيان الواحد‬
‫ جنبا إلى جنب مع مجموعات‬،‫ يمكن تعريف واحد أو أكثر من مجموعات الكيانات اإلضافية‬،‫بدال من ذلك‬
‫ كما‬،‫العالقات الستبدال بعض سمات مجموعة الكيانات االمتحان‬
• ‫ وعدد ج‬،‫ قسم‬،‫دورة مع اسم سمات‬
• ‫ القسم مع سمات‬S- ‫ وتعتمد ككيان ضعيفة مجموعة على مسار‬،‫عدد والتسجيل‬
• ‫ غرفة مع سمات عدد‬r‫ والبناء‬،‫ والقدرة‬،
‫ عرض مخطط‬E-R ‫يوضح استخدام جميع مجموعات الكيانات الثالث األخرى المذكورة‬
Example:
Suppose you are given the following requirements for a simple database for the
National Hockey League (NHL):
 the NHL has many teams,
 each team has a name, a city, a coach, a captain, and a set of players,
 each player belongs to only one team,
 each player has a name, a position (such as left wing or goalie), a skill level,
and a set of injury records,
 a team captain is also a player,
 a game is played between two teams (referred to as host_team and
guest_team) and has a date (such as May 11th, 1999) and a score (such as 4
to 2).
Construct a clean and concise ER diagram
‫مثال‬:
‫)لنفترض أنك أعطيت المتطلبات التالية لقاعدة بيانات بسيطة لدوري الهوكي الوطني (نهل‬:
• ،‫نهل لديها العديد من الفرق‬
• ،‫ ومجموعة من الالعبين‬،‫ كابتن‬،‫ مدرب‬،‫ مدينة‬،‫كل فريق لديه اسم‬
• ،‫كل العب ينتمي إلى فريق واحد فقط‬
• ‫ ومجموعة من‬،‫ ومستوى المهارة‬،)‫ موقف (مثل الجناح األيسر أو حارس المرمى‬،‫كل العب لديه اسم‬
،‫سجالت اإلصابة‬
• ،‫قائد الفريق هو أيضا العب‬
• ‫ لعبت لعبة بين فريقين (المشار إليها باسم‬host_team ‫ و‬Guest_team) ‫ مايو‬11 ‫ولها تاريخ (مثل‬
2 ‫ إلى‬4 ‫) والنتيجة (مثل‬1999).
‫بناء مخطط إير نظيفة وموجزة‬
Short Answer Questions
1. Discuss the role of a high-level data model in the database design
process.
2. What do you understand by Entity-Relationship model?
3. List the various cases where use of a NULL value would be appropriate.
4. Define the following terms: entity, attribute, attribute value, relationship

instance, composite attribute, multivalued attribute, derived attribute,


complex attribute, key attribute, and value set (domain).
5. Explain the difference between an attribute and a value set.
6. What is meant by a recursive relationship type? Give some examples of

recursive relationship types.


7. Define the terms owner entity type, weak entity type, identifying
relationship type, and partial key.
8. Construct a preliminary design of Department, Employee, Product, Car,
Student, Teacher, Mobile, Class, book etc with all its possible attributes.
9. For the following binary relationships, suggest cardinality ratios based on
the common- sense meaning of the entity types.
‫أسئلة اإلجابة القصيرة‬
1 - ‫مناقشة دور نموذج بيانات رفيع المستوى في عملية تصميم قاعدة البيانات‬.
2. ‫ما الذي تفهمه من خالل نموذج العالقة بين الكيانين؟‬
3. ‫إدراج الحاالت المختلفة التي يكون فيها استخدام قيمة نول مناسبا‬.
4. ‫ العالقة‬،‫ قيمة السمة‬،‫ السمة‬،‫ الكيان‬:‫حدد المصطلحات التالية‬
‫ ومجموعة قيمة (مجال‬،‫ سمة مفتاح‬،‫ سمة معقدة‬،‫ سمة مشتقة‬،‫ سمة مولتيفالويد‬،‫ سمة كومبوسيت‬،‫)مثال‬.
5. ‫اشرح الفرق بين السمة ومجموعة القيمة‬.
6. ‫ما المقصود بنوع العالقة المتكرر؟ قدم بعض األمثلة‬

‫أنواع العالقات العودية‬.


7. ‫ والمفتاح الجزئي‬،‫ تحديد نوع العالقة‬،‫ نوع الكيان الضعيف‬،‫تعريف نوع الكيان صاحب الكيان‬.
8. ‫ كتاب الخ مع كل سمات ممكنة‬،‫ فئة‬،‫ موبايل‬،‫ المعلم‬،‫ طالب‬،‫ سيارة‬،‫ المنتج‬،‫ موظف‬،‫بناء التصميم األولي لإلدارة‬.
.9 ‫ يقترح نسب نسبية استنادا إلی المعنی السائد ألنواع الکيانات‬،‫بالنسبة للعالقات الثنائية التالية‬.

Entity 1 Cardinality Ratio Entity 2


1. STUDENT ______________ SOCIAL_SECURITY_CARD
2. STUDENT ______________ TEACHER
3. CLASSROOM ______________ WALL
4. COURSE ______________ TEXTBOOK

Long Answer Questions

1. What is an entity type? What is an entity set? Explain the differences


among

an entity, an entity type, and an entity set.


2. What is a relationship type? Explain the differences among a relationship

instance, a relationship type, and a relationship set.


3. Discuss the conventions for displaying an ER schema as an ER diagram.

4. Draw an ER diagram of UNIVERSITY database, that captures all the


given below requirements. Specify key attribute(s) of each entity set. For
each relationship set, specify structural constraints and participation
constraints.

a. For each STUDENT, the university maintains student Name, student ID,
SSN (Social Security Number), Address, Phone, Birthdate, Gender, Level,
Major (CS, IS, CNET). Both Social Security Number and Student Number
have unique values for each student.

b. Each DEPARTMENT is described by a Name, Department code,


Department Phone, and Office address. Both Name and Code have unique
values for each department.
c. Each COURSE has a Course Name, Description, Course Code, Credit
Hours, Level, and Offering Department. The value of Course Code is unique
for each course.

d. Each SECTION is associated with an Instructor, Semester, Year,


Course, and Section Number. The Section Number distinguishes sections
of the same course that are taught during the same semester.

5. Draw an ER diagram of COMPANY database, that captures all the given


below requirements. Specify key attribute(s) of each entity set. For each
relationship set, specify structural constraints and participation constraints.

a. For each DEPARTMENT, the company maintains Name, department


Number, Manager, Location. Both Name and department Number have
unique values for each student.

b. Each PROJECT is described by a Name, Number, Location, and


Controlling Department. Both Name and Number have unique values for
each department.

c. Each EMPLOYEE has a SSN, Name, Sex, Department, Address, and


Salary. The value of SSN is unique for each employee, whereas Name has
multi value attribute Fname, Minit and Lname.

Draw an ER diagram of ONLINE COURSE REGISRATION database, that


captures all the given below requirements. Specify key attribute(s) of each
entity set. For each relationship set, specify structural constraints and
participation constraints.

a. For each USER, the portal maintains user ID, Name, E-mail. Each user
has a unique ID. Name holds multi valued attributes Fname, Midname,
Lname.

b. Each COURSE is described by a course Code, Description, Category, and


Term. Both Code and Term have unique values for each course.

c. Each LECTUR has a lecturer Title ID, Duration, and Date. The value of ID
is unique for each lecturer.

‫أسئلة اإلجابة الطويلة‬


1. ‫ما هو نوع الكيان؟ ما هي مجموعة الكيان؟ اشرح االختالفات فيما بين‬

‫ ومجموعة الكيان‬،‫ ونوع الكيان‬،‫وكيان‬.


‫ما هو نوع العالقة؟ اشرح االختالفات بين العالقة ‪2.‬‬

‫‪.‬مثال‪ ،‬نوع العالقة‪ ،‬ومجموعة العالقة‬


‫‪.‬مناقشة االتفاقيات لعرض مخطط إير كمخطط إر ‪3.‬‬

‫رسم مخطط إير من قاعدة بيانات الجامعة‪ ،‬الذي يلتقط جميع المتطلبات الواردة أدناه‪ .‬حدد السمة (السمات) الرئيسية لكل ‪4.‬‬
‫‪.‬مجموعة كيانات‪ .‬لكل مجموعة عالقة‪ ،‬حدد القيود الهيكلية والقيود المفروضة على المشاركة‬

‫ا‪ .‬لكل طالب‪ ،‬تحتفظ الجامعة اسم الطالب‪ ،‬هوية الطالب‪ ،‬سن (رقم الضمان االجتماعي)‪ ،‬العنوان‪ ،‬الهاتف‪ ،‬تاريخ الميالد‪،‬‬
‫‪.‬الجنس‪ ،‬المستوى‪ ،‬الرائد (كس‪ ،‬إس‪ ،‬نيت)‪ .‬يحتوي كل من رقم الضمان االجتماعي ورقم الطالب على قيم فريدة لكل طالب‬

‫‪.‬ب‪ .‬يتم وصف كل قسم بواسطة االسم ورمز القسم وعنوان الهاتف وعنوان المكتب‪ .‬لكل من االسم والرمز قيم فريدة لكل قسم‬

‫ج‪ .‬كل دورة لديها اسم الدورة التدريبية‪ ،‬وصف‪ ،‬رمز الدورة‪ ،‬ساعات معتمدة‪ ،‬مستوى‪ ،‬وإدارة العرض‪ .‬قيمة بالطبع بالطبع‬
‫‪.‬هي فريدة من نوعها لكل دورة‬

‫د‪ .‬ويرتبط كل قسم مع مدرس‪ ،‬الفصل الدراسي‪ ،‬السنة‪ ،‬الدورة‪ ،‬ورقم القسم‪ .‬رقم القسم يميز أقسام نفس الدورة التي يتم تدريسها‬
‫‪.‬خالل نفس الفصل الدراسي‬

‫رسم مخطط إير من قاعدة بيانات الشركة‪ ،‬الذي يلتقط جميع المتطلبات الواردة أدناه‪ .‬حدد السمة (السمات) الرئيسية لكل ‪5.‬‬
‫‪.‬مجموعة كيانات‪ .‬لكل مجموعة عالقة‪ ،‬حدد القيود الهيكلية والقيود المفروضة على المشاركة‬

‫‪.‬ا‪ .‬لكل قسم‪ ،‬تحتفظ الشركة االسم‪ ،‬رقم القسم‪ ،‬مدير‪ ،‬الموقع‪ .‬لكل من االسم ورقم القسم قيم فريدة لكل طالب‬

‫‪.‬ب‪ .‬يتم وصف كل مشروع من قبل اسم‪ ،‬رقم‪ ،‬الموقع‪ ،‬وإدارة السيطرة‪ .‬لكل من االسم والرقم قيم فريدة لكل قسم‬

‫ج‪ .‬كل إمبلويي لديه سن‪ ،‬االسم‪ ،‬الجنس‪ ،‬اإلدارة‪ ،‬العنوان‪ ،‬والراتب‪ .‬قيمة سن فريدة من نوعها لكل موظف‪ ،‬في حين أن االسم‬
‫‪.‬له سمة قيمة متعددة فنيم‪ ،‬مينيت و لين‬

‫رسم رسم تخطيطي إير قاعدة بيانات التسجيل على االنترنت‪ ،‬الذي يلتقط كل ما هو مبين أدناه المتطلبات‪ .‬حدد السمة (السمات)‬
‫‪.‬الرئيسية لكل مجموعة كيانات‪ .‬لكل مجموعة عالقة‪ ،‬حدد القيود الهيكلية والقيود المفروضة على المشاركة‬

‫ا‪ .‬لكل مستخدم‪ ،‬البوابة تحتفظ هوية المستخدم‪ ،‬اسم‪ ،‬البريد اإللكتروني‪ .‬لكل مستخدم معرف فريد‪ .‬االسم يحمل سمات متعددة‬
‫‪.‬القيمة فامن‪ ،‬ميدنام‪ ،‬لنيم‬

‫ب‪ .‬يتم وصف كل دورة بواسطة رمز الدورة التدريبية والوصف والفئة والمصطلح‪ .‬كل من كود و تيرم لها قيم فريدة لكل‬
‫‪.‬دورة‬

‫‪.‬ج‪ .‬كل ليتور لديه محاضر معرف عنوان‪ ،‬المدة‪ ،‬والتاريخ‪ .‬قيمة معرف فريدة من نوعها لكل محاضر‬

You might also like