SlideShare una empresa de Scribd logo
1 de 25
6 September 2019 S M Irteza / Dr Rafi Ullah 1
Lesson 07 E-R Modeling
Entity Relationship Modeling
6 September 2019 S M Irteza / Dr Rafi Ullah 2
E-R Model
 Benefits:
1. Provides the big picture (Macro View) of an
organization’s data requirements and relationships.
 Normalization is micro view of the database or the
table
2. Helpful in communicating with managers and end
users.
3. E-R model is concurrently used with normalization
process
6 September 2019 S M Irteza / Dr Rafi Ullah 3
E-R Model Components & E-R Diagram
 1) Entities: (tables)
 Regular Entities
 Weak Entities
 Their existence is dependent on some other entity
in the sense that it cannot exist if that other entity
does not also exists.
 E.g.
Employee Department
6 September 2019 S M Irteza / Dr Rafi Ullah 4
E-R Model Components & E-R Diagram
 2) Attributes
Denoted by an oval shape, they are of 2 basic types:
 Simple or composite
 Base or derived
 Does not exists with in a database , instead it is derived
by using an algorithm etc.
6 September 2019 S M Irteza / Dr Rafi Ullah 5
Employee
ENAME
L-name
MID-
Name
FNAME DOB
Salary
AGE
EMP#
Simple
Attribute Derived
Attribute
Dotted line shows the derived attributes
e.g. age = System clock - DOB
Composite
attribute
6 September 2019 S M Irteza / Dr Rafi Ullah 6
E-R Model Components & E-R Diagram
3) Relationships:
 An Association among entities represented by diamond
shaped symbol in E-R Diagram.
 CONNECTIVITY:
Is used to describe the relationship classification such as
1. One To One
2. One To Many
3. Many To Many
6 September 2019 S M Irteza / Dr Rafi Ullah 7
Examples
Example:
as many profs. Might be in one department. But if one
professor can belong to many departments then ,
1 M
hasDept Professors
M M
hasDept Professors
6 September 2019 S M Irteza / Dr Rafi Ullah 8
Examples
e.g.
e.g.
Must see from both point of views….. !!!
1 1
hasCountry President
M M
ShipsSupplier Parts
6 September 2019 S M Irteza / Dr Rafi Ullah 9
Examples
 e.g
M M
hasStudent Courses
6 September 2019 S M Irteza / Dr Rafi Ullah 10
E-R Model Components & E-R Diagram
4) ENTITY SUPER-TYPE AND SUB-TYPE
 Entities can be represented in a hierarchy.
 The super type entity is composed of several disjoint
(non-overlapping) sub-type entities.
 Super type is usually broken down into several sub
types.
 Attributes that apply to the super type can be inherited
by the sub type.
6 September 2019 S M Irteza / Dr Rafi Ullah 11
ENTITY SUPER-TYPE AND SUB-TYPE
Employee
DOB Salary
Address
Name
AccountantProgrammer
Field
App. Prog. Sys. Prog.
Specialty
Language
Disjoint
6 September 2019 S M Irteza / Dr Rafi Ullah 12
Transforming Entities And Attributes Into
Relations (tables)
 A Set of transformation rules
 One To One
 One To Many
 Many To Many
6 September 2019 S M Irteza / Dr Rafi Ullah 13
One To One
1 1
hasCountry President
Population
CapitalName
DOB
Name Salary……
……
6 September 2019 S M Irteza / Dr Rafi Ullah 14
One To One
 How will we connect the two tables?
 The P.K of president appears in Country table as a F.K
 Or, the P.K of Country Appears in the President as a F.K
 Or BOTH
Country President
Name Population Capital
Pakistan 200,121,234 Islamabad
Iran 35,635,456 Tehran
India 1,156,311,334 New Delhi
Yemen 23,000,000 Sana’a
Name DOB Education
Asif Zardari 26/7/1955 B.Sc
Ahmedinejad 28/10/1956 PhD
Pratibha Patel 19/12/1934 MS, LLB
Ali Abdullah Saleh 1/2/1945 B.Sc
6 September 2019 S M Irteza / Dr Rafi Ullah 15
One To One
Name Population Capital GMI
Usa 12342323 Washington 12354
Pak 121234 Islamabad 1234
Aus 35635456 Sydney 12453
Ind 4563334 Madras 2355
…. ….. …… …..
Country President
F.KP.K
Name DOB Education C_Name
Asif Zardari 26/7/1955 B.Sc Pakistan
Mahmood
Ahmedinejad
28/10/1956 PhD
Iran
Pratibha Patel 19/12/1934 MS, LLB
India
Ali Abdullah Saleh 1/2/1945 B.Sc
Yemen
6 September 2019 S M Irteza / Dr Rafi Ullah 16
One To Many
1 M
hasDept Professors
Chairman
BudgetName
S#
Name Office……
……
6 September 2019 S M Irteza / Dr Rafi Ullah 17
One To Many
 How to represent the relation b/w these two tables having
one to many relationship?
 MANY side of the relationship must include the P.K of
ONE side as a F.K.
 Integrity Rules must Hold
 If ‘Bio’ is deleted from Dept, all entries in Prof for ‘Bio’
are Deleted.
Name Chair Budget Sect
CS Prof. X 124334 Ms. abc
Math Prof. Y 23423 Ms. J
Acc Prof. Z 234 Mr. G
Bio Prof. S 23423 Mr. Kol
…. ….. …… …..
Dept
PName S# Office Phone
Pervez 1930 … …
Bashir 1950 … …
Boota 1940 … …
Mali 1920 … …
Bush 1800 … …
Prof
6 September 2019 S M Irteza / Dr Rafi Ullah 18
One To Many
Name Chair Budget Sect
CS Prof. X 124334 Ms. abc
Math Prof. Y 23423 Ms. J
Acc Prof. Z 234 Mr. G
Bio Prof. S 23423 Mr. Kol
…. ….. …… …..
Dept
PName S# Office Phone Dept
Prof. Y 1 … … CS
Prof Z 2 … … Math
Prof X 3 … … CS
Prof A 4 … … Bio
Prof. X 3 … … Phy
Prof
F.KP.K
6 September 2019 S M Irteza / Dr Rafi Ullah 19
Many To Many
M M
hasSuppliers Parts
S# SNAME STATUS CITY
S1 Smith 20 London
S2 Jones 10 Paris
S3 Blake 30 Paris
S4 Clark 20 London
S5 Adams 30 Athens
Supplier S
P# PNAME COLOR WEIGHT CITY
P1 Nut Red 12 London
P2 Bolt Green 17 Paris
P3 Screw Blue 17 Rome
P4 Screw Red 14 London
P5 Cam Blue 12 Paris
P6 Cog Red 19 London
Parts P
6 September 2019 S M Irteza / Dr Rafi Ullah 20
Many To Many
 In M-to-M , cases adding one more attribute does NOT
work, we must create another Table.
 The relationship needs a table of its own called
BRIDGE IDENTITY.
 New Table is composed of P.K of the connected entities
and it may also include additional attributes.
M M
SPSuppliers Parts
BRIDGE IDENTITY
6 September 2019 S M Irteza / Dr Rafi Ullah 21
Many To Many
 The Shipment table contains both P.K from the two
previous tables.
S# SNAME STATUS CITY
S1 Smith 20 London
S2 Jones 10 Paris
S3 Blake 30 Paris
S4 Clark 20 London
S5 Adams 30 Athens
Supplier S
P# PNAME COLOR WEIGHT CITY
P1 Nut Red 12 London
P2 Bolt Green 17 Paris
P3 Screw Blue 17 Rome
P4 Screw Red 14 London
P5 Cam Blue 12 Paris
P6 Cog Red 19 London
Parts P
S# P# QTY
S1 P1 300
S1 P2 200
S1 P3 400
S1 P4 200
S1 P5 100
S1 P6 100
S2 P1 300
S2 P2 400
S3 P2 200
S4 P2 200
S4 P4 300
S4 P5 400
Shipment SP
P.K
P.K
F.K for table PF.K for table S
6 September 2019 S M Irteza / Dr Rafi Ullah 22
Many To Many
 Student(SS# , Name…)
 Enrollment(SS# , Course# , Grade)
 Classes(Course# , Date , Classroom)
 So We use a Bridge entity for joining two tables
having M to M relationship.
M M
EnrollsStudent Classes
BRIDGE IDENTITY
6 September 2019 S M Irteza / Dr Rafi Ullah 23
Example
Professor
Student
Dept
Classes
Offers
Has
Employee
Chair
Teaches
Advises
Enrolls
6 September 2019 S M Irteza / Dr Rafi Ullah 24
1. So we have to build 5 tables
2. Then Normalize the tables.
Profes
sor
Student
Dept
Class
es
Offers
Has
Employee
Chair
Teaches
Advise
s
Enrolls
6 September 2019 S M Irteza / Dr Rafi Ullah 25
END
END
(slides taken from M Ali Shahid’s original slides)

Más contenido relacionado

Más de Muhammad Sikandar Mustafa (12)

software characteristics
software characteristicssoftware characteristics
software characteristics
 
overview introduction to Software Engineering
overview introduction to Software Engineeringoverview introduction to Software Engineering
overview introduction to Software Engineering
 
5. software process model
5. software process model5. software process model
5. software process model
 
Lesson05 relational languages sql
Lesson05 relational languages sqlLesson05 relational languages sql
Lesson05 relational languages sql
 
Lesson03 the relational model
Lesson03 the relational modelLesson03 the relational model
Lesson03 the relational model
 
Lesson02 database system architecture
Lesson02 database system architectureLesson02 database system architecture
Lesson02 database system architecture
 
Lesson01 Database introduction
Lesson01 Database introductionLesson01 Database introduction
Lesson01 Database introduction
 
Lesson00 intro to databases
Lesson00 intro to databasesLesson00 intro to databases
Lesson00 intro to databases
 
Lesson10 Database security
Lesson10 Database security Lesson10 Database security
Lesson10 Database security
 
Lesson08 tm recovery
Lesson08 tm recoveryLesson08 tm recovery
Lesson08 tm recovery
 
Lesson06 database design
Lesson06 database designLesson06 database design
Lesson06 database design
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
 

Último

%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 

Último (20)

%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 

Lesson07 e r modelling

  • 1. 6 September 2019 S M Irteza / Dr Rafi Ullah 1 Lesson 07 E-R Modeling Entity Relationship Modeling
  • 2. 6 September 2019 S M Irteza / Dr Rafi Ullah 2 E-R Model  Benefits: 1. Provides the big picture (Macro View) of an organization’s data requirements and relationships.  Normalization is micro view of the database or the table 2. Helpful in communicating with managers and end users. 3. E-R model is concurrently used with normalization process
  • 3. 6 September 2019 S M Irteza / Dr Rafi Ullah 3 E-R Model Components & E-R Diagram  1) Entities: (tables)  Regular Entities  Weak Entities  Their existence is dependent on some other entity in the sense that it cannot exist if that other entity does not also exists.  E.g. Employee Department
  • 4. 6 September 2019 S M Irteza / Dr Rafi Ullah 4 E-R Model Components & E-R Diagram  2) Attributes Denoted by an oval shape, they are of 2 basic types:  Simple or composite  Base or derived  Does not exists with in a database , instead it is derived by using an algorithm etc.
  • 5. 6 September 2019 S M Irteza / Dr Rafi Ullah 5 Employee ENAME L-name MID- Name FNAME DOB Salary AGE EMP# Simple Attribute Derived Attribute Dotted line shows the derived attributes e.g. age = System clock - DOB Composite attribute
  • 6. 6 September 2019 S M Irteza / Dr Rafi Ullah 6 E-R Model Components & E-R Diagram 3) Relationships:  An Association among entities represented by diamond shaped symbol in E-R Diagram.  CONNECTIVITY: Is used to describe the relationship classification such as 1. One To One 2. One To Many 3. Many To Many
  • 7. 6 September 2019 S M Irteza / Dr Rafi Ullah 7 Examples Example: as many profs. Might be in one department. But if one professor can belong to many departments then , 1 M hasDept Professors M M hasDept Professors
  • 8. 6 September 2019 S M Irteza / Dr Rafi Ullah 8 Examples e.g. e.g. Must see from both point of views….. !!! 1 1 hasCountry President M M ShipsSupplier Parts
  • 9. 6 September 2019 S M Irteza / Dr Rafi Ullah 9 Examples  e.g M M hasStudent Courses
  • 10. 6 September 2019 S M Irteza / Dr Rafi Ullah 10 E-R Model Components & E-R Diagram 4) ENTITY SUPER-TYPE AND SUB-TYPE  Entities can be represented in a hierarchy.  The super type entity is composed of several disjoint (non-overlapping) sub-type entities.  Super type is usually broken down into several sub types.  Attributes that apply to the super type can be inherited by the sub type.
  • 11. 6 September 2019 S M Irteza / Dr Rafi Ullah 11 ENTITY SUPER-TYPE AND SUB-TYPE Employee DOB Salary Address Name AccountantProgrammer Field App. Prog. Sys. Prog. Specialty Language Disjoint
  • 12. 6 September 2019 S M Irteza / Dr Rafi Ullah 12 Transforming Entities And Attributes Into Relations (tables)  A Set of transformation rules  One To One  One To Many  Many To Many
  • 13. 6 September 2019 S M Irteza / Dr Rafi Ullah 13 One To One 1 1 hasCountry President Population CapitalName DOB Name Salary…… ……
  • 14. 6 September 2019 S M Irteza / Dr Rafi Ullah 14 One To One  How will we connect the two tables?  The P.K of president appears in Country table as a F.K  Or, the P.K of Country Appears in the President as a F.K  Or BOTH Country President Name Population Capital Pakistan 200,121,234 Islamabad Iran 35,635,456 Tehran India 1,156,311,334 New Delhi Yemen 23,000,000 Sana’a Name DOB Education Asif Zardari 26/7/1955 B.Sc Ahmedinejad 28/10/1956 PhD Pratibha Patel 19/12/1934 MS, LLB Ali Abdullah Saleh 1/2/1945 B.Sc
  • 15. 6 September 2019 S M Irteza / Dr Rafi Ullah 15 One To One Name Population Capital GMI Usa 12342323 Washington 12354 Pak 121234 Islamabad 1234 Aus 35635456 Sydney 12453 Ind 4563334 Madras 2355 …. ….. …… ….. Country President F.KP.K Name DOB Education C_Name Asif Zardari 26/7/1955 B.Sc Pakistan Mahmood Ahmedinejad 28/10/1956 PhD Iran Pratibha Patel 19/12/1934 MS, LLB India Ali Abdullah Saleh 1/2/1945 B.Sc Yemen
  • 16. 6 September 2019 S M Irteza / Dr Rafi Ullah 16 One To Many 1 M hasDept Professors Chairman BudgetName S# Name Office…… ……
  • 17. 6 September 2019 S M Irteza / Dr Rafi Ullah 17 One To Many  How to represent the relation b/w these two tables having one to many relationship?  MANY side of the relationship must include the P.K of ONE side as a F.K.  Integrity Rules must Hold  If ‘Bio’ is deleted from Dept, all entries in Prof for ‘Bio’ are Deleted. Name Chair Budget Sect CS Prof. X 124334 Ms. abc Math Prof. Y 23423 Ms. J Acc Prof. Z 234 Mr. G Bio Prof. S 23423 Mr. Kol …. ….. …… ….. Dept PName S# Office Phone Pervez 1930 … … Bashir 1950 … … Boota 1940 … … Mali 1920 … … Bush 1800 … … Prof
  • 18. 6 September 2019 S M Irteza / Dr Rafi Ullah 18 One To Many Name Chair Budget Sect CS Prof. X 124334 Ms. abc Math Prof. Y 23423 Ms. J Acc Prof. Z 234 Mr. G Bio Prof. S 23423 Mr. Kol …. ….. …… ….. Dept PName S# Office Phone Dept Prof. Y 1 … … CS Prof Z 2 … … Math Prof X 3 … … CS Prof A 4 … … Bio Prof. X 3 … … Phy Prof F.KP.K
  • 19. 6 September 2019 S M Irteza / Dr Rafi Ullah 19 Many To Many M M hasSuppliers Parts S# SNAME STATUS CITY S1 Smith 20 London S2 Jones 10 Paris S3 Blake 30 Paris S4 Clark 20 London S5 Adams 30 Athens Supplier S P# PNAME COLOR WEIGHT CITY P1 Nut Red 12 London P2 Bolt Green 17 Paris P3 Screw Blue 17 Rome P4 Screw Red 14 London P5 Cam Blue 12 Paris P6 Cog Red 19 London Parts P
  • 20. 6 September 2019 S M Irteza / Dr Rafi Ullah 20 Many To Many  In M-to-M , cases adding one more attribute does NOT work, we must create another Table.  The relationship needs a table of its own called BRIDGE IDENTITY.  New Table is composed of P.K of the connected entities and it may also include additional attributes. M M SPSuppliers Parts BRIDGE IDENTITY
  • 21. 6 September 2019 S M Irteza / Dr Rafi Ullah 21 Many To Many  The Shipment table contains both P.K from the two previous tables. S# SNAME STATUS CITY S1 Smith 20 London S2 Jones 10 Paris S3 Blake 30 Paris S4 Clark 20 London S5 Adams 30 Athens Supplier S P# PNAME COLOR WEIGHT CITY P1 Nut Red 12 London P2 Bolt Green 17 Paris P3 Screw Blue 17 Rome P4 Screw Red 14 London P5 Cam Blue 12 Paris P6 Cog Red 19 London Parts P S# P# QTY S1 P1 300 S1 P2 200 S1 P3 400 S1 P4 200 S1 P5 100 S1 P6 100 S2 P1 300 S2 P2 400 S3 P2 200 S4 P2 200 S4 P4 300 S4 P5 400 Shipment SP P.K P.K F.K for table PF.K for table S
  • 22. 6 September 2019 S M Irteza / Dr Rafi Ullah 22 Many To Many  Student(SS# , Name…)  Enrollment(SS# , Course# , Grade)  Classes(Course# , Date , Classroom)  So We use a Bridge entity for joining two tables having M to M relationship. M M EnrollsStudent Classes BRIDGE IDENTITY
  • 23. 6 September 2019 S M Irteza / Dr Rafi Ullah 23 Example Professor Student Dept Classes Offers Has Employee Chair Teaches Advises Enrolls
  • 24. 6 September 2019 S M Irteza / Dr Rafi Ullah 24 1. So we have to build 5 tables 2. Then Normalize the tables. Profes sor Student Dept Class es Offers Has Employee Chair Teaches Advise s Enrolls
  • 25. 6 September 2019 S M Irteza / Dr Rafi Ullah 25 END END (slides taken from M Ali Shahid’s original slides)