SlideShare a Scribd company logo
1 of 34
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

More Related Content

Viewers also liked

Enhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) ModelingEnhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) Modelingsontumax
 
Physical database design(database)
Physical database design(database)Physical database design(database)
Physical database design(database)welcometofacebook
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)welcometofacebook
 
Hospital Management system Database design
Hospital Management system Database designHospital Management system Database design
Hospital Management system Database designElias Dinsa
 
Logical design vs physical design
Logical design vs physical designLogical design vs physical design
Logical design vs physical designMd. Mahedi Mahfuj
 
Er & eer to relational mapping
Er & eer to relational mappingEr & eer to relational mapping
Er & eer to relational mappingsaurabhshertukde
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMSkoolkampus
 
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)Beat Signer
 
System Analysis and Design
System Analysis and DesignSystem Analysis and Design
System Analysis and DesignAamir Abbas
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ARADHYAYANA
 

Viewers also liked (12)

Enhanced ER(database)
Enhanced ER(database)Enhanced ER(database)
Enhanced ER(database)
 
Enhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) ModelingEnhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) Modeling
 
Physical database design(database)
Physical database design(database)Physical database design(database)
Physical database design(database)
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)
 
Hospital Management system Database design
Hospital Management system Database designHospital Management system Database design
Hospital Management system Database design
 
Logical design vs physical design
Logical design vs physical designLogical design vs physical design
Logical design vs physical design
 
Er & eer to relational mapping
Er & eer to relational mappingEr & eer to relational mapping
Er & eer to relational mapping
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
EER Model
EER ModelEER Model
EER Model
 
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
 
System Analysis and Design
System Analysis and DesignSystem Analysis and Design
System Analysis and Design
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
 

More from Esmatullah Adel

Enhanced entity relationship model
Enhanced entity relationship modelEnhanced entity relationship model
Enhanced entity relationship modelEsmatullah Adel
 
Relationship in database
Relationship in databaseRelationship in database
Relationship in databaseEsmatullah Adel
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to databaseEsmatullah Adel
 

More from Esmatullah Adel (7)

Introduction to sql_02
Introduction to sql_02Introduction to sql_02
Introduction to sql_02
 
Introduction to sql_01
Introduction to sql_01Introduction to sql_01
Introduction to sql_01
 
Enhanced entity relationship model
Enhanced entity relationship modelEnhanced entity relationship model
Enhanced entity relationship model
 
Relationship in database
Relationship in databaseRelationship in database
Relationship in database
 
Identifiers in database
Identifiers in databaseIdentifiers in database
Identifiers in database
 
Requirements analysis
Requirements analysisRequirements analysis
Requirements analysis
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 

Mapping in database

  • 2. 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
  • 3. 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
  • 4. 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
  • 5. Continue… 1:55 AM Gharjistan University Computer Science Faculty Farah Branch 5
  • 6. 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
  • 7. In case of composite 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… Computer Science Faculty, Database1 9
  • 10. 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
  • 11. 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
  • 12. 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
  • 13. 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
  • 14. 3. Map binary relationship… Computer Science Faculty, Database1 14
  • 15. 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
  • 16. 3. Map binary relationship… Computer Science Faculty, Database1 16
  • 17. 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
  • 18. 3. Map binary relationship… Computer Science Faculty, Database1 18
  • 19. 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
  • 20. 4. Map associative entity… Computer Science Faculty, Database1 20
  • 21. 4. Map associative entity… Computer Science Faculty, Database1 21
  • 22. Continue… • Sometimes the data modeler assign an identifier called surrogate identifier, to the associative entity type on ER Diagram. •‫یک‬ ‫دیتا‬ ‫ساز‬ ‫مدل‬ ‫اوقات‬ ‫بعضی‬ ‫شرکت‬ ‫موجودیت‬ ‫نوع‬ ‫به‬ ‫را‬ ‫شناسه‬ ‫شن‬ ‫بنام‬ ‫که‬ ‫میکند‬ ‫تعیین‬ ‫پذیر‬‫اسه‬ ‫میشود‬ ‫یاد‬ ‫جایگزین‬. Computer Science Faculty, Database1 22
  • 24. 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
  • 25. 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
  • 27. 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
  • 29. 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
  • 30. Continue… 1:55 AM Gharjistan University Computer Science Faculty Farah Branch 30
  • 31. 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
  • 32. 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
  • 34. 1:55 AM Gharjistan University Computer Science Faculty Farah Branch 34