Mapping
‫نگاشت‬
‫کننده‬ ‫تهیه‬:‫عادل‬ ‫هللا‬ ‫عصمت‬
Topics:
• Transformation EER diagram in relations:
• Map regular entities
• Map weak entity
• Map binary relationships
• Map associative entity
• Map unary relationships
• Map ternary relationships
• Mapping supertype/subtype relationships
•‫دیاگرام‬ ‫تبدیل‬EER‫ها‬ ‫جدول‬ ‫به‬
•‫عادی‬ ‫موجودیت‬ ‫نگاشت‬
•‫ضعیف‬ ‫موجودیت‬ ‫نگاشت‬
•‫دوگانه‬ ‫ارتباط‬ ‫نگاشت‬
•‫پذیر‬ ‫شرکت‬ ‫موجودیت‬ ‫نگاشت‬
•‫یگانه‬ ‫ارتباط‬ ‫نگاشت‬
•‫گانه‬ ‫سه‬ ‫ارتباط‬ ‫نگاشت‬
•‫اصلی‬ ‫نمونه‬ ‫ارتباط‬ ‫نگاشت‬/‫فرع‬‫ی‬
1:55 AM
Gharjistan University Computer Science
Faculty Farah Branch
2
Transformation EER diagram in relations:
• In this we will convert ER
and EER diagrams that were
developed in conceptual
design into Relational
database schemas.
• By using the following steps:
•‫نمودن‬ ‫تبدیل‬ ‫پروسه‬ ‫از‬ ‫عبارت‬
‫های‬ ‫دیاگرام‬ER‫و‬EER(‫در‬ ‫که‬
‫بود‬ ‫شده‬ ‫ساخته‬ ‫مفهومی‬ ‫دیزاین‬)‫ب‬‫ه‬
‫میباشد‬ ‫ها‬ ‫جدول‬.
•‫ذیل‬ ‫مراحل‬ ‫استفاده‬ ‫با‬:
Computer Science Faculty, Database1 3
1. Map regular entities:
• Each regular entity type in
an ER Diagram is
transformed into a relation.
• Name same as to entity
name.
• Attributes become
attributes of relation.
• Identifier become Primary
key.
•‫یک‬ ‫در‬ ‫عادی‬ ‫موجودیت‬ ‫نوع‬ ‫هر‬
‫دیاگرام‬ER‫تبدیل‬ ‫جدول‬ ‫یک‬ ‫به‬
‫میشود‬.
•‫چیز‬ ‫یک‬ ‫موجودیت‬ ‫نام‬ ‫با‬ ‫آن‬ ‫نام‬
‫میباشد‬.
•‫صفات‬ ‫موجودیت‬ ‫خاصه‬ ‫صفات‬
‫میگیرد‬ ‫قرار‬ ‫جدول‬ ‫خاصه‬.
•،‫شناسه‬‫میشود‬ ‫جدول‬ ‫اصلی‬ ‫کلید‬.
Computer Science Faculty, Database1 4
Continue…
1:55 AM
Gharjistan University Computer Science
Faculty Farah Branch
5
In case of composite attributes:
• When any entity have
composite attributes ,only
the simple component
attributes of the composite
attribute are included in
the new relation.
•‫خاص‬ ‫صفات‬ ‫موجودیت‬ ‫یک‬ ‫وقتیکه‬‫ه‬
‫صفا‬ ‫فقط‬ ،‫باشد‬ ‫داشته‬ ‫را‬ ‫مرکب‬‫ت‬
‫خاصه‬ ‫صفت‬ ‫ساده‬ ‫جزئی‬ ‫خاصه‬
‫جدید‬ ‫جدول‬ ‫شامل‬ ‫را‬ ‫مرکب‬
‫میسازیم‬.
Computer Science Faculty, Database1 6
In case of composite attributes…
Computer Science Faculty, Database1 7
Multi value attribute:
• When a regular entity type
contains a multi valued
attribute, two new relations
are created .
• First Relation contain all of
the attributes of the entity
type except the multi
valued attribute.
• Second Relation contain
primary key ,plus its
attribute.
•‫عادی‬ ‫موجودیت‬ ‫نوع‬ ‫یک‬ ‫زمانیکه‬
‫قیمته‬ ‫چندین‬ ‫خاصه‬ ‫صفت‬ ‫دارای‬
‫ساخته‬ ‫جدید‬ ‫جدول‬ ‫دو‬ ‫پس‬ ‫باشد‬
‫میشود‬.
•‫خاصه‬ ‫صفات‬ ‫تمام‬ ‫اول‬ ‫جدول‬
‫چن‬ ‫خاصه‬ ‫صفت‬ ‫از‬ ‫بجز‬ ‫موجودیت‬‫د‬
‫بوده‬ ‫داراء‬ ‫را‬ ‫قیمته‬.
•‫با‬ ‫اصلی‬ ‫کلید‬ ‫شامل‬ ‫دوم‬ ‫جدول‬
‫قیمته‬ ‫چند‬ ‫خاصه‬ ‫صفت‬ ‫اضافه‬
‫میباشد‬.
Computer Science Faculty, Database1 8
Multi value attribute…
Computer Science Faculty, Database1 9
2. Map weak entity:
• Weak entity has no
independence existence
,but exists only through an
identifying relationship with
another entity type called
the owner.
a) For each weak entity
create a relation associate
its attributes.
•‫مستق‬ ‫وجود‬ ‫هیچ‬ ‫ضعیف‬ ‫موجودیت‬‫ل‬
‫موجودی‬ ‫توسط‬ ‫میتواند‬ ‫اما‬ ،‫نداشته‬‫ت‬
‫شود‬ ‫موجود‬ ‫قوی‬.
(a‫یک‬ ‫ضعیف‬ ‫موجودیت‬ ‫هر‬ ‫برای‬
‫صفات‬ ‫تمام‬ ‫و‬ ‫بسازید‬ ‫را‬ ‫جدول‬
‫ستون‬ ‫منحیث‬ ‫را‬ ‫موجودیت‬ ‫خاصه‬
‫دهید‬ ‫قرار‬ ‫جدول‬ ‫های‬.
Computer Science Faculty, Database1 10
2. Map weak entity…
b) Include the primary key of
the identifying relation as a
foreign key attribute in this
new relation.
• For example: Driver
,,,,license
• When driver die its license
finish automatically.
(b‫را‬ ‫قوی‬ ‫موجودیت‬ ‫اصلی‬ ‫کلید‬
‫جدول‬ ‫در‬ ‫خارجی‬ ‫کلید‬ ‫منحیث‬
‫دهید‬ ‫قرار‬ ‫جدید‬.
•‫مثال‬ ‫بطور‬:‫لسانس‬ ‫و‬ ‫راننده‬
•‫آن‬ ‫لسانس‬ ‫میرد‬ ‫می‬ ‫راننده‬ ‫زمانیکه‬
‫میکند‬ ‫پیدا‬ ‫خاتمه‬.
Computer Science Faculty, Database1 11
3. Map binary relationship:
• Binary relationship is
mapped according to its
cardinalities.
1. Mapping binary 1:M
relationships:
• First create two tables for
each entity.
•‫کاردینال‬ ‫براساس‬ ‫دوگانه‬ ‫ارتباط‬‫یتی‬
‫آن‬map‫میشود‬.
.1‫چ‬ ‫به‬ ‫یک‬ ‫دوگانه‬ ‫ارتباط‬ ‫نگاشت‬‫ند‬:
•‫هر‬ ‫برای‬ ‫را‬ ‫جدول‬ ‫دو‬ ‫ابتدا‬
‫کنید‬ ‫درست‬ ‫موجودیت‬.
Computer Science Faculty, Database1 12
3. Map binary relationship…
• Next include the primary
key attribute of the entity
on the one side of the
relationship as a foreign key
in the relation that is on the
many side of the
relationship.
• Example as of customer
and order.
•‫ایک‬ ‫موجودیت‬ ‫اصلی‬ ‫کلید‬ ‫سپس‬‫در‬ ‫ه‬
‫دارد‬ ‫قرار‬ ‫ارتباط‬ ‫یگانه‬ ‫سمت‬
‫ایک‬ ‫موجودیت‬ ‫خارجی‬ ‫کلید‬ ‫منحیث‬‫ه‬
‫قرا‬ ‫دارد‬ ‫قرار‬ ‫ارتباط‬ ‫چند‬ ‫سمت‬ ‫در‬‫ر‬
‫دهید‬.
•‫مثال‬ ‫بطور‬:customer‫و‬order
Computer Science Faculty, Database1 13
3. Map binary relationship…
Computer Science Faculty, Database1 14
3. Map binary relationship…
2. Map Binary M:M:
• When two entities have
M:M relationship then we
create a new relation C.
• This new relation contains
primary key of both
Relations (A and B).
•‫دوگانه‬ ‫ارتباط‬ ‫نگاشت‬‫به‬ ‫چند‬‫چن‬‫د‬:
•‫ب‬ ‫چند‬ ‫ارتباط‬ ‫موجودیت‬ ‫دو‬ ‫زمانیکه‬‫ه‬
‫جدو‬ ‫یک‬ ‫ما‬ ‫سپس‬ ‫باشد‬ ‫داشته‬ ‫چند‬‫ل‬
‫جدید‬C‫میسازیم‬ ‫را‬.
•‫د‬ ‫هر‬ ‫اصلی‬ ‫کلید‬ ‫شامل‬ ‫جدید‬ ‫جدول‬‫و‬
‫جدول‬A‫و‬B‫میباشد‬.
Computer Science Faculty, Database1 15
3. Map binary relationship…
Computer Science Faculty, Database1 16
3. Map binary relationship…
• Map binary 1:1 Relation:
• Create two relations for
each entity.
• Put primary key of
Mandatory one side in
optional side.
•‫به‬ ‫یک‬ ‫دوگانه‬ ‫ارتباط‬ ‫نگاشت‬‫یک‬:
•‫را‬ ‫جدول‬ ‫یک‬ ‫موجودیت‬ ‫هر‬ ‫برای‬
‫کنید‬ ‫درست‬.
•‫را‬ ‫اجباری‬ ‫یک‬ ‫سمت‬ ‫اصلی‬ ‫کلید‬
‫یک‬ ‫سمت‬ ‫خارجی‬ ‫کلید‬ ‫منحیث‬
‫دهید‬ ‫قرار‬ ‫اختیاری‬.
Computer Science Faculty, Database1 17
3. Map binary relationship…
Computer Science Faculty, Database1 18
4. Map associative entity:
• Associative entity is
mapped like a many to
many binary relationship.
• Create three tables.
• Third for associative entity.
• An identifier is assigned to
the associative relation.
•‫ارتب‬ ‫مانند‬ ‫پذیر‬ ‫شرکت‬ ‫موجودیت‬‫اط‬
‫میشو‬ ‫نگاشته‬ ‫چند‬ ‫به‬ ‫چند‬ ‫دوگانه‬‫د‬.
•‫بسازید‬ ‫را‬ ‫جدول‬ ‫سه‬.
•‫شرکت‬ ‫موجودیت‬ ‫برای‬ ‫سوم‬ ‫جدول‬
‫پذیر‬.
•‫پذیر‬ ‫شرکت‬ ‫جدول‬ ‫به‬ ‫شناسه‬ ‫یک‬
‫میشود‬ ‫تعیین‬.
Computer Science Faculty, Database1 19
4. Map associative entity…
Computer Science Faculty, Database1 20
4. Map associative entity…
Computer Science Faculty, Database1 21
Continue…
• Sometimes the data
modeler assign an identifier
called surrogate identifier,
to the associative entity
type on ER Diagram.
•‫یک‬ ‫دیتا‬ ‫ساز‬ ‫مدل‬ ‫اوقات‬ ‫بعضی‬
‫شرکت‬ ‫موجودیت‬ ‫نوع‬ ‫به‬ ‫را‬ ‫شناسه‬
‫شن‬ ‫بنام‬ ‫که‬ ‫میکند‬ ‫تعیین‬ ‫پذیر‬‫اسه‬
‫میشود‬ ‫یاد‬ ‫جایگزین‬.
Computer Science Faculty, Database1 22
Continue…
Computer Science Faculty, Database1 23
5. Map Unary Relationships:
• Also called recursive
relationship.
• The two most important
cases are:
1. One to many
2. Many to Many
• A relation is formed for
entity.
• Then a foreign attribute is
added within the same
relation that references the
primary key value.
•‫بنام‬ ‫همچنان‬ ‫یک‬ ‫درجه‬ ‫ارتباط‬
‫میشود‬ ‫یاد‬ ‫بازگشتی‬ ‫ارتباط‬.
•‫دارد‬ ‫حالت‬ ‫سه‬:
•‫یک‬ ‫به‬ ‫یک‬
•‫چند‬ ‫به‬ ‫یک‬
Computer Science Faculty, Database1 24
Continue…
1. Unary one to many
relationship:
• The entity type in the unary
relationship is mapped to a
relation.
• Then a foreign key attribute
is added to the same
relation that references the
primary key values in the
same relation.
•‫یک‬ ‫درجه‬ ‫چند‬ ‫به‬ ‫یک‬ ‫ارتباط‬:
•‫یک‬ ‫درجه‬ ‫ارتباط‬ ‫در‬ ‫موجودیت‬ ‫نوع‬
‫میشود‬ ‫نگاشته‬ ‫جدول‬ ‫یک‬ ‫به‬.
•‫خارجی‬ ‫شناسه‬ ‫خاصه‬ ‫صفت‬ ‫سپس‬
‫به‬ ‫که‬ ‫شده‬ ‫اضافه‬ ‫جدول‬ ‫عین‬ ‫به‬
‫خود‬ ‫در‬ ‫اصلی‬ ‫کلید‬ ‫های‬ ‫قیمت‬
‫میدهد‬ ‫مرجع‬ ‫جدول‬.
Computer Science Faculty, Database1 25
Cont…
Computer Science Faculty, Database1 26
Continue…
• Unary M:M Relationship:
• Two relations are created,
one for entity and other is
an associative relation.
• The primary key of
associative relation consist
of two attribute.
• Example:
•‫یک‬ ‫درجه‬ ‫چند‬ ‫به‬ ‫چند‬ ‫ارتباط‬:
•‫برای‬ ‫یکی‬ ‫میشود‬ ‫ساخته‬ ‫جدول‬ ‫دو‬
‫برای‬ ‫دیگری‬ ‫و‬ ‫موجودیت‬ ‫نوع‬
‫پذیر‬ ‫شرکت‬ ‫جدول‬.
•‫ش‬ ‫پذیر‬ ‫شرکت‬ ‫جدول‬ ‫اصلی‬ ‫کلید‬‫امل‬
‫میباشد‬ ‫خاصه‬ ‫صفت‬ ‫دو‬.
•‫مثال‬ ‫بطور‬:
Computer Science Faculty, Database1 27
Cont…
Computer Science Faculty, Database1 28
6. Map Ternary Relationships:
• Convert ternary relationship
to an associative entity.
• Create a relation for the
associative entity.
• Its Primary key may consist
of 3 foreign keys.
•‫یک‬ ‫به‬ ‫را‬ ‫سه‬ ‫درجه‬ ‫ارتباط‬
‫ک‬ ‫تبدیل‬ ‫پذیر‬ ‫شرکت‬ ‫موجودیت‬‫نید‬.
•‫موجودیت‬ ‫برای‬ ‫را‬ ‫جدول‬ ‫یک‬
‫بسازید‬ ‫پذیر‬ ‫شرکت‬.
•‫سه‬ ‫از‬ ‫مرکب‬ ‫ممکن‬ ‫آن‬ ‫اصلی‬ ‫کلید‬
‫باشد‬ ‫خارجی‬ ‫کلید‬.
Computer Science Faculty, Database1 29
Continue…
1:55 AM
Gharjistan University Computer Science
Faculty Farah Branch
30
7. Map super type/subtype relations:
• Create a separate relation
for the super type and for
each of its sub types.
• Assign the attributes that
are common to all members
of the super type, including
the primary key to the
relation created for the
super type.
•‫برای‬ ‫جدا‬ ‫جدول‬ ‫یک‬super type
‫از‬ ‫یک‬ ‫هر‬ ‫برای‬ ‫و‬sub type‫ها‬
‫بسازید‬.
•‫برای‬ ‫ایکه‬ ‫جدول‬ ‫به‬super type
‫شده‬ ‫ساخته‬attribute‫را‬ ‫های‬
‫تمام‬ ‫بین‬ ‫که‬ ‫بدهید‬sub type‫ها‬
‫اص‬ ‫کلید‬ ‫شمول‬ ‫به‬ ‫هستند‬ ‫مشترک‬‫لی‬.
1:55 AM
Gharjistan University Computer Science
Faculty Farah Branch
31
Continue…
• Assign the primary key of
the super type and only
those attributes that are
unique to the sub type to
the relation for each sub
type.
• Assign one (or more)
attributes of the super type
to function as the sub type
discriminator.
•‫از‬ ‫یک‬ ‫هر‬ ‫برای‬ ‫ایکه‬ ‫جدول‬ ‫به‬
sub type‫کلید‬ ‫میشود‬ ‫ساخته‬ ‫ها‬
‫اصلی‬super type‫فقط‬ ‫و‬
attribute‫همان‬ ‫به‬ ‫مربوط‬ ‫هایکه‬
sub type‫بدهید‬ ‫است‬.
•‫ک‬ ‫تفکیک‬ ‫منحیث‬ ‫ایکه‬ ‫تابع‬ ‫به‬‫ننده‬
sub type‫ا‬ ‫بیشتر‬ ‫یا‬ ‫و‬ ‫یک‬ ‫بوده‬‫ز‬
‫خاصه‬ ‫صفت‬ ‫یک‬super type‫را‬
‫بدهید‬.
1:55 AM
Gharjistan University Computer Science
Faculty Farah Branch
32
Continue…
Computer Science Faculty, Database1 33
1:55 AM
Gharjistan University Computer Science
Faculty Farah Branch
34

Mapping in database

  • 1.
  • 2.
    Topics: • Transformation EERdiagram in relations: • Map regular entities • Map weak entity • Map binary relationships • Map associative entity • Map unary relationships • Map ternary relationships • Mapping supertype/subtype relationships •‫دیاگرام‬ ‫تبدیل‬EER‫ها‬ ‫جدول‬ ‫به‬ •‫عادی‬ ‫موجودیت‬ ‫نگاشت‬ •‫ضعیف‬ ‫موجودیت‬ ‫نگاشت‬ •‫دوگانه‬ ‫ارتباط‬ ‫نگاشت‬ •‫پذیر‬ ‫شرکت‬ ‫موجودیت‬ ‫نگاشت‬ •‫یگانه‬ ‫ارتباط‬ ‫نگاشت‬ •‫گانه‬ ‫سه‬ ‫ارتباط‬ ‫نگاشت‬ •‫اصلی‬ ‫نمونه‬ ‫ارتباط‬ ‫نگاشت‬/‫فرع‬‫ی‬ 1:55 AM Gharjistan University Computer Science Faculty Farah Branch 2
  • 3.
    Transformation EER diagramin relations: • In this we will convert ER and EER diagrams that were developed in conceptual design into Relational database schemas. • By using the following steps: •‫نمودن‬ ‫تبدیل‬ ‫پروسه‬ ‫از‬ ‫عبارت‬ ‫های‬ ‫دیاگرام‬ER‫و‬EER(‫در‬ ‫که‬ ‫بود‬ ‫شده‬ ‫ساخته‬ ‫مفهومی‬ ‫دیزاین‬)‫ب‬‫ه‬ ‫میباشد‬ ‫ها‬ ‫جدول‬. •‫ذیل‬ ‫مراحل‬ ‫استفاده‬ ‫با‬: Computer Science Faculty, Database1 3
  • 4.
    1. Map regularentities: • Each regular entity type in an ER Diagram is transformed into a relation. • Name same as to entity name. • Attributes become attributes of relation. • Identifier become Primary key. •‫یک‬ ‫در‬ ‫عادی‬ ‫موجودیت‬ ‫نوع‬ ‫هر‬ ‫دیاگرام‬ER‫تبدیل‬ ‫جدول‬ ‫یک‬ ‫به‬ ‫میشود‬. •‫چیز‬ ‫یک‬ ‫موجودیت‬ ‫نام‬ ‫با‬ ‫آن‬ ‫نام‬ ‫میباشد‬. •‫صفات‬ ‫موجودیت‬ ‫خاصه‬ ‫صفات‬ ‫میگیرد‬ ‫قرار‬ ‫جدول‬ ‫خاصه‬. •،‫شناسه‬‫میشود‬ ‫جدول‬ ‫اصلی‬ ‫کلید‬. Computer Science Faculty, Database1 4
  • 5.
    Continue… 1:55 AM Gharjistan UniversityComputer Science Faculty Farah Branch 5
  • 6.
    In case ofcomposite attributes: • When any entity have composite attributes ,only the simple component attributes of the composite attribute are included in the new relation. •‫خاص‬ ‫صفات‬ ‫موجودیت‬ ‫یک‬ ‫وقتیکه‬‫ه‬ ‫صفا‬ ‫فقط‬ ،‫باشد‬ ‫داشته‬ ‫را‬ ‫مرکب‬‫ت‬ ‫خاصه‬ ‫صفت‬ ‫ساده‬ ‫جزئی‬ ‫خاصه‬ ‫جدید‬ ‫جدول‬ ‫شامل‬ ‫را‬ ‫مرکب‬ ‫میسازیم‬. Computer Science Faculty, Database1 6
  • 7.
    In case ofcomposite attributes… Computer Science Faculty, Database1 7
  • 8.
    Multi value attribute: •When a regular entity type contains a multi valued attribute, two new relations are created . • First Relation contain all of the attributes of the entity type except the multi valued attribute. • Second Relation contain primary key ,plus its attribute. •‫عادی‬ ‫موجودیت‬ ‫نوع‬ ‫یک‬ ‫زمانیکه‬ ‫قیمته‬ ‫چندین‬ ‫خاصه‬ ‫صفت‬ ‫دارای‬ ‫ساخته‬ ‫جدید‬ ‫جدول‬ ‫دو‬ ‫پس‬ ‫باشد‬ ‫میشود‬. •‫خاصه‬ ‫صفات‬ ‫تمام‬ ‫اول‬ ‫جدول‬ ‫چن‬ ‫خاصه‬ ‫صفت‬ ‫از‬ ‫بجز‬ ‫موجودیت‬‫د‬ ‫بوده‬ ‫داراء‬ ‫را‬ ‫قیمته‬. •‫با‬ ‫اصلی‬ ‫کلید‬ ‫شامل‬ ‫دوم‬ ‫جدول‬ ‫قیمته‬ ‫چند‬ ‫خاصه‬ ‫صفت‬ ‫اضافه‬ ‫میباشد‬. Computer Science Faculty, Database1 8
  • 9.
    Multi value attribute… ComputerScience Faculty, Database1 9
  • 10.
    2. Map weakentity: • Weak entity has no independence existence ,but exists only through an identifying relationship with another entity type called the owner. a) For each weak entity create a relation associate its attributes. •‫مستق‬ ‫وجود‬ ‫هیچ‬ ‫ضعیف‬ ‫موجودیت‬‫ل‬ ‫موجودی‬ ‫توسط‬ ‫میتواند‬ ‫اما‬ ،‫نداشته‬‫ت‬ ‫شود‬ ‫موجود‬ ‫قوی‬. (a‫یک‬ ‫ضعیف‬ ‫موجودیت‬ ‫هر‬ ‫برای‬ ‫صفات‬ ‫تمام‬ ‫و‬ ‫بسازید‬ ‫را‬ ‫جدول‬ ‫ستون‬ ‫منحیث‬ ‫را‬ ‫موجودیت‬ ‫خاصه‬ ‫دهید‬ ‫قرار‬ ‫جدول‬ ‫های‬. Computer Science Faculty, Database1 10
  • 11.
    2. Map weakentity… b) Include the primary key of the identifying relation as a foreign key attribute in this new relation. • For example: Driver ,,,,license • When driver die its license finish automatically. (b‫را‬ ‫قوی‬ ‫موجودیت‬ ‫اصلی‬ ‫کلید‬ ‫جدول‬ ‫در‬ ‫خارجی‬ ‫کلید‬ ‫منحیث‬ ‫دهید‬ ‫قرار‬ ‫جدید‬. •‫مثال‬ ‫بطور‬:‫لسانس‬ ‫و‬ ‫راننده‬ •‫آن‬ ‫لسانس‬ ‫میرد‬ ‫می‬ ‫راننده‬ ‫زمانیکه‬ ‫میکند‬ ‫پیدا‬ ‫خاتمه‬. Computer Science Faculty, Database1 11
  • 12.
    3. Map binaryrelationship: • Binary relationship is mapped according to its cardinalities. 1. Mapping binary 1:M relationships: • First create two tables for each entity. •‫کاردینال‬ ‫براساس‬ ‫دوگانه‬ ‫ارتباط‬‫یتی‬ ‫آن‬map‫میشود‬. .1‫چ‬ ‫به‬ ‫یک‬ ‫دوگانه‬ ‫ارتباط‬ ‫نگاشت‬‫ند‬: •‫هر‬ ‫برای‬ ‫را‬ ‫جدول‬ ‫دو‬ ‫ابتدا‬ ‫کنید‬ ‫درست‬ ‫موجودیت‬. Computer Science Faculty, Database1 12
  • 13.
    3. Map binaryrelationship… • Next include the primary key attribute of the entity on the one side of the relationship as a foreign key in the relation that is on the many side of the relationship. • Example as of customer and order. •‫ایک‬ ‫موجودیت‬ ‫اصلی‬ ‫کلید‬ ‫سپس‬‫در‬ ‫ه‬ ‫دارد‬ ‫قرار‬ ‫ارتباط‬ ‫یگانه‬ ‫سمت‬ ‫ایک‬ ‫موجودیت‬ ‫خارجی‬ ‫کلید‬ ‫منحیث‬‫ه‬ ‫قرا‬ ‫دارد‬ ‫قرار‬ ‫ارتباط‬ ‫چند‬ ‫سمت‬ ‫در‬‫ر‬ ‫دهید‬. •‫مثال‬ ‫بطور‬:customer‫و‬order Computer Science Faculty, Database1 13
  • 14.
    3. Map binaryrelationship… Computer Science Faculty, Database1 14
  • 15.
    3. Map binaryrelationship… 2. Map Binary M:M: • When two entities have M:M relationship then we create a new relation C. • This new relation contains primary key of both Relations (A and B). •‫دوگانه‬ ‫ارتباط‬ ‫نگاشت‬‫به‬ ‫چند‬‫چن‬‫د‬: •‫ب‬ ‫چند‬ ‫ارتباط‬ ‫موجودیت‬ ‫دو‬ ‫زمانیکه‬‫ه‬ ‫جدو‬ ‫یک‬ ‫ما‬ ‫سپس‬ ‫باشد‬ ‫داشته‬ ‫چند‬‫ل‬ ‫جدید‬C‫میسازیم‬ ‫را‬. •‫د‬ ‫هر‬ ‫اصلی‬ ‫کلید‬ ‫شامل‬ ‫جدید‬ ‫جدول‬‫و‬ ‫جدول‬A‫و‬B‫میباشد‬. Computer Science Faculty, Database1 15
  • 16.
    3. Map binaryrelationship… Computer Science Faculty, Database1 16
  • 17.
    3. Map binaryrelationship… • Map binary 1:1 Relation: • Create two relations for each entity. • Put primary key of Mandatory one side in optional side. •‫به‬ ‫یک‬ ‫دوگانه‬ ‫ارتباط‬ ‫نگاشت‬‫یک‬: •‫را‬ ‫جدول‬ ‫یک‬ ‫موجودیت‬ ‫هر‬ ‫برای‬ ‫کنید‬ ‫درست‬. •‫را‬ ‫اجباری‬ ‫یک‬ ‫سمت‬ ‫اصلی‬ ‫کلید‬ ‫یک‬ ‫سمت‬ ‫خارجی‬ ‫کلید‬ ‫منحیث‬ ‫دهید‬ ‫قرار‬ ‫اختیاری‬. Computer Science Faculty, Database1 17
  • 18.
    3. Map binaryrelationship… Computer Science Faculty, Database1 18
  • 19.
    4. Map associativeentity: • Associative entity is mapped like a many to many binary relationship. • Create three tables. • Third for associative entity. • An identifier is assigned to the associative relation. •‫ارتب‬ ‫مانند‬ ‫پذیر‬ ‫شرکت‬ ‫موجودیت‬‫اط‬ ‫میشو‬ ‫نگاشته‬ ‫چند‬ ‫به‬ ‫چند‬ ‫دوگانه‬‫د‬. •‫بسازید‬ ‫را‬ ‫جدول‬ ‫سه‬. •‫شرکت‬ ‫موجودیت‬ ‫برای‬ ‫سوم‬ ‫جدول‬ ‫پذیر‬. •‫پذیر‬ ‫شرکت‬ ‫جدول‬ ‫به‬ ‫شناسه‬ ‫یک‬ ‫میشود‬ ‫تعیین‬. Computer Science Faculty, Database1 19
  • 20.
    4. Map associativeentity… Computer Science Faculty, Database1 20
  • 21.
    4. Map associativeentity… Computer Science Faculty, Database1 21
  • 22.
    Continue… • Sometimes thedata modeler assign an identifier called surrogate identifier, to the associative entity type on ER Diagram. •‫یک‬ ‫دیتا‬ ‫ساز‬ ‫مدل‬ ‫اوقات‬ ‫بعضی‬ ‫شرکت‬ ‫موجودیت‬ ‫نوع‬ ‫به‬ ‫را‬ ‫شناسه‬ ‫شن‬ ‫بنام‬ ‫که‬ ‫میکند‬ ‫تعیین‬ ‫پذیر‬‫اسه‬ ‫میشود‬ ‫یاد‬ ‫جایگزین‬. Computer Science Faculty, Database1 22
  • 23.
  • 24.
    5. Map UnaryRelationships: • Also called recursive relationship. • The two most important cases are: 1. One to many 2. Many to Many • A relation is formed for entity. • Then a foreign attribute is added within the same relation that references the primary key value. •‫بنام‬ ‫همچنان‬ ‫یک‬ ‫درجه‬ ‫ارتباط‬ ‫میشود‬ ‫یاد‬ ‫بازگشتی‬ ‫ارتباط‬. •‫دارد‬ ‫حالت‬ ‫سه‬: •‫یک‬ ‫به‬ ‫یک‬ •‫چند‬ ‫به‬ ‫یک‬ Computer Science Faculty, Database1 24
  • 25.
    Continue… 1. Unary oneto many relationship: • The entity type in the unary relationship is mapped to a relation. • Then a foreign key attribute is added to the same relation that references the primary key values in the same relation. •‫یک‬ ‫درجه‬ ‫چند‬ ‫به‬ ‫یک‬ ‫ارتباط‬: •‫یک‬ ‫درجه‬ ‫ارتباط‬ ‫در‬ ‫موجودیت‬ ‫نوع‬ ‫میشود‬ ‫نگاشته‬ ‫جدول‬ ‫یک‬ ‫به‬. •‫خارجی‬ ‫شناسه‬ ‫خاصه‬ ‫صفت‬ ‫سپس‬ ‫به‬ ‫که‬ ‫شده‬ ‫اضافه‬ ‫جدول‬ ‫عین‬ ‫به‬ ‫خود‬ ‫در‬ ‫اصلی‬ ‫کلید‬ ‫های‬ ‫قیمت‬ ‫میدهد‬ ‫مرجع‬ ‫جدول‬. Computer Science Faculty, Database1 25
  • 26.
  • 27.
    Continue… • Unary M:MRelationship: • Two relations are created, one for entity and other is an associative relation. • The primary key of associative relation consist of two attribute. • Example: •‫یک‬ ‫درجه‬ ‫چند‬ ‫به‬ ‫چند‬ ‫ارتباط‬: •‫برای‬ ‫یکی‬ ‫میشود‬ ‫ساخته‬ ‫جدول‬ ‫دو‬ ‫برای‬ ‫دیگری‬ ‫و‬ ‫موجودیت‬ ‫نوع‬ ‫پذیر‬ ‫شرکت‬ ‫جدول‬. •‫ش‬ ‫پذیر‬ ‫شرکت‬ ‫جدول‬ ‫اصلی‬ ‫کلید‬‫امل‬ ‫میباشد‬ ‫خاصه‬ ‫صفت‬ ‫دو‬. •‫مثال‬ ‫بطور‬: Computer Science Faculty, Database1 27
  • 28.
  • 29.
    6. Map TernaryRelationships: • Convert ternary relationship to an associative entity. • Create a relation for the associative entity. • Its Primary key may consist of 3 foreign keys. •‫یک‬ ‫به‬ ‫را‬ ‫سه‬ ‫درجه‬ ‫ارتباط‬ ‫ک‬ ‫تبدیل‬ ‫پذیر‬ ‫شرکت‬ ‫موجودیت‬‫نید‬. •‫موجودیت‬ ‫برای‬ ‫را‬ ‫جدول‬ ‫یک‬ ‫بسازید‬ ‫پذیر‬ ‫شرکت‬. •‫سه‬ ‫از‬ ‫مرکب‬ ‫ممکن‬ ‫آن‬ ‫اصلی‬ ‫کلید‬ ‫باشد‬ ‫خارجی‬ ‫کلید‬. Computer Science Faculty, Database1 29
  • 30.
    Continue… 1:55 AM Gharjistan UniversityComputer Science Faculty Farah Branch 30
  • 31.
    7. Map supertype/subtype relations: • Create a separate relation for the super type and for each of its sub types. • Assign the attributes that are common to all members of the super type, including the primary key to the relation created for the super type. •‫برای‬ ‫جدا‬ ‫جدول‬ ‫یک‬super type ‫از‬ ‫یک‬ ‫هر‬ ‫برای‬ ‫و‬sub type‫ها‬ ‫بسازید‬. •‫برای‬ ‫ایکه‬ ‫جدول‬ ‫به‬super type ‫شده‬ ‫ساخته‬attribute‫را‬ ‫های‬ ‫تمام‬ ‫بین‬ ‫که‬ ‫بدهید‬sub type‫ها‬ ‫اص‬ ‫کلید‬ ‫شمول‬ ‫به‬ ‫هستند‬ ‫مشترک‬‫لی‬. 1:55 AM Gharjistan University Computer Science Faculty Farah Branch 31
  • 32.
    Continue… • Assign theprimary key of the super type and only those attributes that are unique to the sub type to the relation for each sub type. • Assign one (or more) attributes of the super type to function as the sub type discriminator. •‫از‬ ‫یک‬ ‫هر‬ ‫برای‬ ‫ایکه‬ ‫جدول‬ ‫به‬ sub type‫کلید‬ ‫میشود‬ ‫ساخته‬ ‫ها‬ ‫اصلی‬super type‫فقط‬ ‫و‬ attribute‫همان‬ ‫به‬ ‫مربوط‬ ‫هایکه‬ sub type‫بدهید‬ ‫است‬. •‫ک‬ ‫تفکیک‬ ‫منحیث‬ ‫ایکه‬ ‫تابع‬ ‫به‬‫ننده‬ sub type‫ا‬ ‫بیشتر‬ ‫یا‬ ‫و‬ ‫یک‬ ‫بوده‬‫ز‬ ‫خاصه‬ ‫صفت‬ ‫یک‬super type‫را‬ ‫بدهید‬. 1:55 AM Gharjistan University Computer Science Faculty Farah Branch 32
  • 33.
  • 34.
    1:55 AM Gharjistan UniversityComputer Science Faculty Farah Branch 34