SlideShare uma empresa Scribd logo
1 de 27
How to translate ER
Model to Relational
       Model
     By- Mr.Sanket Senapati
          Mechanical
 RITAM Engg. College Rayagada.
Review - Concepts
     Relational Model is made up of tables

•   A row of table      = a relational instance/tuple
•   A column of table   = an attribute
•   A table             = a schema/relation
•   Cardinality         = number of rows
•   Degree              = number of columns
Review - Example

                                              Attribute




                                                          Cardinality =
tuple/relational
instance              SID    Name    Major       GPA
                      1234   John        CS       2.8
                      5678   Mary        EE       3.6
                                                             2


                              4 Degree


                      A Schema / Relation
From ER Model to Relational
              Model
  So… how do we convert an ER diagram into a
               table?? Simple!!
Basic Ideas:
 Build a table for each entity set
 Build a table for each relationship set if necessary (more
  on this later)
 Make a column in the table for each attribute in the entity
  set
 Indivisibility Rule and Ordering Rule
 Primary Key
Example – Strong Entity Set
  SID           Name                         SSN           Name


           Student               Advisor           Professor


 Major                                                         Dept
                     GPA




SID      Name Major    GPA                 SSN     Name        Dept
1234     John   CS         2.8             9999    Smith       Math
5678     Mary   EE         3.6             8888    Lee          CS
Representation of Weak Entity Set
• Weak Entity Set Cannot exists alone
• To build a table/schema for weak entity set
  – Construct a table with one column for each attribute in
    the weak entity set
  – Remember to include discriminator
  – Augment one extra column on the right side of the
    table, put in there the primary key of the Strong Entity
    Set (the entity set that the weak entity set is
    depending on)
  – Primary Key of the weak entity set = Discriminator +
    foreign key
Example – Weak Entity Set
                                                 Age
 SID           Name                                              Name


          Student                   owns                  Children


Major               GPA




                                     Age          Name        Parent_SID
                                     10            Bart              1234
                                      8            Lisa              5678

* Primary key of Children is Parent_SID + Name
Representation of Relationship Set
       --This is a little more complicated--
 Unary/Binary Relationship set
    Depends on the cardinality and participation of the relationship
    Two possible approaches
 N-ary (multiple) Relationship set
    Primary Key Issue
 Identifying Relationship
    No relational model representation necessary
Representing Relationship Set
            Unary/Binary Relationship
• For one-to-one relationship w/out total participation
   – Build a table with two columns, one column for each
     participating entity set’s primary key. Add successive
     columns, one for each descriptive attributes of the
     relationship set (if any).
• For one-to-one relationship with one entity set having
  total participation
   – Augment one extra column on the right side of the
     table of the entity set with total participation, put in
     there the primary key of the entity set without
     complete participation as per to the relationship.
Example – One-to-One Relationship Set
                                        Degree
 SID           Name                                           ID Code


          Student                   study                 Major


Major                GPA




                    SID       Maj_ID Co        S_Degree
                 9999             07             1234
                 8888             05             5678

* Primary key can be either SID or Maj_ID_Co
Example – One-to-One Relationship Set
                                         Condition
 SID           Name       1:1                                    S/N #
                          Relationship

          Student                    Have               Laptop


Major               GPA                                          Brand




   SID         Name          Major           GPA     LP_S/N      Hav_Cond
  9999          Bart       Economy           -4.0    123-456       Own
  8888          Lisa        Physics          4.0     567-890       Loan


* Primary key can be either SID or LP_S/N
Representing Relationship Set
          Unary/Binary Relationship
• For one-to-many relationship w/out total
  participation
   – Same thing as one-to-one
• For one-to-many/many-to-one relationship with
  one entity set having total participation on “many”
  side
   – Augment one extra column on the right side of
     the table of the entity set on the “many” side,
     put in there the primary key of the entity set
     on the “one” side as per to the relationship.
Example – Many-to-One Relationship Set
                                           Semester
 SID             Name       N:1                                   SSN
                            Relationship

           Student                     Advisor             Professor


Major                 GPA                               Dept       Name




   SID          Name           Major             GPA    Pro_SSN    Ad_Sem
  9999            Bart       Economy             -4.0   123-456    Fall 2006
  8888            Lisa        Physics            4.0    567-890    Fall 2005


* Primary key of this table is SID
Representing Relationship Set
          Unary/Binary Relationship
• For many-to-many relationship
   – Same thing as one-to-one relationship without
     total participation.
   – Primary key of this new schema is the union
     of the foreign keys of both entity sets.
   – No augmentation approach possible…
Representing Relationship Set
                 N-ary Relationship
• Intuitively Simple
   – Build a new table with as many columns as there are
     attributes for the union of the primary keys of all
     participating entity sets.
   – Augment additional columns for descriptive attributes
     of the relationship set (if necessary)
   – The primary key of this table is the union of all
     primary keys of entity sets that are on “many” side
   – That is it, we are done.
Example – N-ary Relationship Set
P-Key1
                                         D-Attribute              A-Key
           E-Set 1


P-Key2                             A relationship           Another Set
          E-Set 2

P-Key3
           E-Set 3



             P-Key1       P-Key2          P-Key3          A-Key   D-Attribute
              9999          8888           7777           6666        Yes
              1234          5678           9012           3456        No


* Primary key of this table is P-Key1 + P-Key2 + P-Key3
Representing Relationship Set
              Identifying Relationship
• This is what you have to know
  – You DON’T have to build a table/schema for the
    identifying relationship set once you have built a
    table/schema for the corresponding weak entity set
  – Reason:
     • A special case of one-to-many with total participation
     • Reduce Redundancy
Representing Composite Attribute
• Relational Model Indivisibility Rule Applies
• One column for each component attribute
• NO column for the composite attribute itself

 SSN           Name

                             SSN     Name        Street        City
   Professor                 9999   Dr. Smith   50 1st St.   Fake City
                             8888   Dr. Lee      1 B St.     San Jose
               Address



 Street               City
Representing Multivalue Attribute
• For each multivalue attribute in an entity
  set/relationship set
   – Build a new relation schema with two columns
   – One column for the primary keys of the entity
     set/relationship set that has the multivalue attribute
   – Another column for the multivalue attributes. Each
     cell of this column holds only one value. So each
     value is represented as an unique tuple
   – Primary key for this schema is the union of all
     attributes
Example – Multivalue attribute
 SID             Name                              The primary key for this
                                                   table is Student_SID +
                                                   Children, the union of all
                                    Children       attributes
           Student


 Major                GPA



                                  Stud_SID     Children
                                   1234        Johnson
                                   1234         Mary
SID      Name    Major      GPA
                                   5678          Bart
1234     John        CS     2.8
                                   5678          Lisa
5678     Homer       EE     3.6
                                   5678        Maggie
Representing Class Hierarchy
• Two general approaches depending on
  disjointness and completeness
  – For non-disjoint and/or non-complete class hierarchy:
     • create a table for each super class entity set
       according to normal entity set translation method.
     • Create a table for each subclass entity set with a
       column for each of the attributes of that entity set
       plus one for each attributes of the primary key of
       the super class entity set
     • This primary key from super class entity set is also
       used as the primary key for this new table
Example             SSN           Name


                                                             Person

       SID             Status
                                                    Gender
                                        ISA
                   Student


   Major                      GPA
                                              SSN          Name       Gender
                                              1234         Homer       Male
                                              5678         Marge      Female

SSN          SID     Status     Major   GPA
1234     9999         Full       CS     2.8
5678     8888         Part       EE     3.6
Representing Class Hierarchy
• Two general approaches depending on
  disjointness and completeness
  – For disjoint AND complete mapping class hierarchy:
  – DO NOT create a table for the super class entity set
  – Create a table for each subclass entity set include all
    attributes of that subclass entity set and attributes of
    the superclass entity set

  – Simple and Intuitive enough, need example?
SSN         Name
Example                                          No table created for
                                                 superclass entity set
                                  SJSU people




                                   ISA
 SID
              Student                                      Faculty
                              Disjoint and
                              Complete mapping
   Major                GPA                      Dept




SSN    Name      SID     Major    GPA        SSN        Name             Dept
1234   John     9999      CS       2.8       1234       Homer            C.S.
5678   Mary     8888      EE       3.6       5678       Marge            Math
Representing Aggregation
           Name                           SSN                Name


      Student                   Advisor            Professor


                                                                Dept
                SID


                                                            Name
                                member
Primary Key of Advisor
                                                     Dept


                         SID     Code
                                                                Code
                         1234      04
                                          Primary key of Dept
                         5678      08
Finally, we are done
Applause??
• Thank you…

Mais conteúdo relacionado

Mais procurados

Database Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity TypesDatabase Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity Typesaakanksha s
 
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...Mustafa Kamel Mohammadi
 
Er Model Nandha&Mani
Er Model Nandha&ManiEr Model Nandha&Mani
Er Model Nandha&Maniguest1e0229a
 
Data Modeling Using the EntityRelationship (ER) Model
Data Modeling Using the EntityRelationship (ER) ModelData Modeling Using the EntityRelationship (ER) Model
Data Modeling Using the EntityRelationship (ER) Modelsontumax
 
Data Modeling and Database Design 2nd Edition by Umanath Scamell Solution Manual
Data Modeling and Database Design 2nd Edition by Umanath Scamell Solution ManualData Modeling and Database Design 2nd Edition by Umanath Scamell Solution Manual
Data Modeling and Database Design 2nd Edition by Umanath Scamell Solution Manualendokayle
 
Entity relationship diagram
Entity relationship diagramEntity relationship diagram
Entity relationship diagramHaseeb
 
Special lecture er diagram
Special lecture er diagramSpecial lecture er diagram
Special lecture er diagramNiaz Ali
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship ModelNeil Neelesh
 
Chapter-3 Data Modeling Using the Entity-Relationship Model
Chapter-3  Data Modeling Using the Entity-Relationship ModelChapter-3  Data Modeling Using the Entity-Relationship Model
Chapter-3 Data Modeling Using the Entity-Relationship ModelRaj vardhan
 
Schema relationship to E-R diagram
Schema relationship to E-R diagramSchema relationship to E-R diagram
Schema relationship to E-R diagramBadrul Alam
 
Design issues with constraints of E-R model
Design issues with constraints of E-R modelDesign issues with constraints of E-R model
Design issues with constraints of E-R modelPaurav Shah
 
Mapping ER and EER Model
Mapping ER and EER ModelMapping ER and EER Model
Mapping ER and EER ModelMary Brinda
 
Data modeling using the entity relationship model
Data modeling using the entity relationship modelData modeling using the entity relationship model
Data modeling using the entity relationship modelJafar Nesargi
 
Database Systems - Entity Relationship Modeling (Chapter 4/2)
Database Systems - Entity Relationship Modeling (Chapter 4/2)Database Systems - Entity Relationship Modeling (Chapter 4/2)
Database Systems - Entity Relationship Modeling (Chapter 4/2)Vidyasagar Mundroy
 
3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) modelKumar
 

Mais procurados (20)

Database Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity TypesDatabase Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity Types
 
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
 
Er Model Nandha&Mani
Er Model Nandha&ManiEr Model Nandha&Mani
Er Model Nandha&Mani
 
DBMS PPT
DBMS PPTDBMS PPT
DBMS PPT
 
1869495 er diagrams
1869495 er diagrams1869495 er diagrams
1869495 er diagrams
 
Er model
Er modelEr model
Er model
 
Data Modeling Using the EntityRelationship (ER) Model
Data Modeling Using the EntityRelationship (ER) ModelData Modeling Using the EntityRelationship (ER) Model
Data Modeling Using the EntityRelationship (ER) Model
 
Data Modeling and Database Design 2nd Edition by Umanath Scamell Solution Manual
Data Modeling and Database Design 2nd Edition by Umanath Scamell Solution ManualData Modeling and Database Design 2nd Edition by Umanath Scamell Solution Manual
Data Modeling and Database Design 2nd Edition by Umanath Scamell Solution Manual
 
Entity relationship diagram
Entity relationship diagramEntity relationship diagram
Entity relationship diagram
 
Special lecture er diagram
Special lecture er diagramSpecial lecture er diagram
Special lecture er diagram
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Chapter-3 Data Modeling Using the Entity-Relationship Model
Chapter-3  Data Modeling Using the Entity-Relationship ModelChapter-3  Data Modeling Using the Entity-Relationship Model
Chapter-3 Data Modeling Using the Entity-Relationship Model
 
Schema relationship to E-R diagram
Schema relationship to E-R diagramSchema relationship to E-R diagram
Schema relationship to E-R diagram
 
Design issues with constraints of E-R model
Design issues with constraints of E-R modelDesign issues with constraints of E-R model
Design issues with constraints of E-R model
 
Mapping ER and EER Model
Mapping ER and EER ModelMapping ER and EER Model
Mapping ER and EER Model
 
Data modeling using the entity relationship model
Data modeling using the entity relationship modelData modeling using the entity relationship model
Data modeling using the entity relationship model
 
Database Systems - Entity Relationship Modeling (Chapter 4/2)
Database Systems - Entity Relationship Modeling (Chapter 4/2)Database Systems - Entity Relationship Modeling (Chapter 4/2)
Database Systems - Entity Relationship Modeling (Chapter 4/2)
 
enhanced er diagram
enhanced er diagramenhanced er diagram
enhanced er diagram
 
3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model
 
Er diagrams presentation
Er diagrams presentationEr diagrams presentation
Er diagrams presentation
 

Destaque

Supplemental Data Manager - What is it? What are some use cases? How do I get...
Supplemental Data Manager - What is it? What are some use cases? How do I get...Supplemental Data Manager - What is it? What are some use cases? How do I get...
Supplemental Data Manager - What is it? What are some use cases? How do I get...finitsolutions
 
Module 5 oodb systems semantic db systems
Module 5 oodb systems  semantic db systemsModule 5 oodb systems  semantic db systems
Module 5 oodb systems semantic db systemsTaher Barodawala
 
Business Process Modeling
Business Process ModelingBusiness Process Modeling
Business Process ModelingAng Chen
 
Basic database analysis(database)
Basic database analysis(database)Basic database analysis(database)
Basic database analysis(database)welcometofacebook
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Coursepeter_marklund
 
Object Oriented Dbms
Object Oriented DbmsObject Oriented Dbms
Object Oriented Dbmsmaryeem
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Mudasir Qazi
 

Destaque (8)

Supplemental Data Manager - What is it? What are some use cases? How do I get...
Supplemental Data Manager - What is it? What are some use cases? How do I get...Supplemental Data Manager - What is it? What are some use cases? How do I get...
Supplemental Data Manager - What is it? What are some use cases? How do I get...
 
Module 5 oodb systems semantic db systems
Module 5 oodb systems  semantic db systemsModule 5 oodb systems  semantic db systems
Module 5 oodb systems semantic db systems
 
L7 er2
L7 er2L7 er2
L7 er2
 
Business Process Modeling
Business Process ModelingBusiness Process Modeling
Business Process Modeling
 
Basic database analysis(database)
Basic database analysis(database)Basic database analysis(database)
Basic database analysis(database)
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Object Oriented Dbms
Object Oriented DbmsObject Oriented Dbms
Object Oriented Dbms
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)
 

Semelhante a E r model

Semelhante a E r model (20)

Ch 6
Ch 6Ch 6
Ch 6
 
Database management system
Database management systemDatabase management system
Database management system
 
DBMS UNIT1
DBMS UNIT1DBMS UNIT1
DBMS UNIT1
 
erdiagramspresentation-150826044953-lva1-app6891.pdf
erdiagramspresentation-150826044953-lva1-app6891.pdferdiagramspresentation-150826044953-lva1-app6891.pdf
erdiagramspresentation-150826044953-lva1-app6891.pdf
 
Er diagrams presentation
Er diagrams presentationEr diagrams presentation
Er diagrams presentation
 
Er model
Er modelEr model
Er model
 
Data Models.pptx
Data Models.pptxData Models.pptx
Data Models.pptx
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).ppt
 
UNIT II DBMS.pptx
UNIT II DBMS.pptxUNIT II DBMS.pptx
UNIT II DBMS.pptx
 
rdbmsdol.pptx
rdbmsdol.pptxrdbmsdol.pptx
rdbmsdol.pptx
 
rdbmsdol.pptx
rdbmsdol.pptxrdbmsdol.pptx
rdbmsdol.pptx
 
Relational Model
Relational ModelRelational Model
Relational Model
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
RDBMS ERD
RDBMS ERDRDBMS ERD
RDBMS ERD
 
Entity Relationship Diagram2
Entity Relationship Diagram2Entity Relationship Diagram2
Entity Relationship Diagram2
 
DBMS Unit 2 ppt.ppt
DBMS Unit 2 ppt.pptDBMS Unit 2 ppt.ppt
DBMS Unit 2 ppt.ppt
 
er-models.pptx
er-models.pptxer-models.pptx
er-models.pptx
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptx
 
ER MODEL.pptx
ER MODEL.pptxER MODEL.pptx
ER MODEL.pptx
 
L3_1564812219285.pptx
L3_1564812219285.pptxL3_1564812219285.pptx
L3_1564812219285.pptx
 

Último

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Último (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 

E r model

  • 1. How to translate ER Model to Relational Model By- Mr.Sanket Senapati Mechanical RITAM Engg. College Rayagada.
  • 2. Review - Concepts Relational Model is made up of tables • A row of table = a relational instance/tuple • A column of table = an attribute • A table = a schema/relation • Cardinality = number of rows • Degree = number of columns
  • 3. Review - Example Attribute Cardinality = tuple/relational instance SID Name Major GPA 1234 John CS 2.8 5678 Mary EE 3.6 2 4 Degree A Schema / Relation
  • 4. From ER Model to Relational Model So… how do we convert an ER diagram into a table?? Simple!! Basic Ideas:  Build a table for each entity set  Build a table for each relationship set if necessary (more on this later)  Make a column in the table for each attribute in the entity set  Indivisibility Rule and Ordering Rule  Primary Key
  • 5. Example – Strong Entity Set SID Name SSN Name Student Advisor Professor Major Dept GPA SID Name Major GPA SSN Name Dept 1234 John CS 2.8 9999 Smith Math 5678 Mary EE 3.6 8888 Lee CS
  • 6. Representation of Weak Entity Set • Weak Entity Set Cannot exists alone • To build a table/schema for weak entity set – Construct a table with one column for each attribute in the weak entity set – Remember to include discriminator – Augment one extra column on the right side of the table, put in there the primary key of the Strong Entity Set (the entity set that the weak entity set is depending on) – Primary Key of the weak entity set = Discriminator + foreign key
  • 7. Example – Weak Entity Set Age SID Name Name Student owns Children Major GPA Age Name Parent_SID 10 Bart 1234 8 Lisa 5678 * Primary key of Children is Parent_SID + Name
  • 8. Representation of Relationship Set --This is a little more complicated--  Unary/Binary Relationship set  Depends on the cardinality and participation of the relationship  Two possible approaches  N-ary (multiple) Relationship set  Primary Key Issue  Identifying Relationship  No relational model representation necessary
  • 9. Representing Relationship Set Unary/Binary Relationship • For one-to-one relationship w/out total participation – Build a table with two columns, one column for each participating entity set’s primary key. Add successive columns, one for each descriptive attributes of the relationship set (if any). • For one-to-one relationship with one entity set having total participation – Augment one extra column on the right side of the table of the entity set with total participation, put in there the primary key of the entity set without complete participation as per to the relationship.
  • 10. Example – One-to-One Relationship Set Degree SID Name ID Code Student study Major Major GPA SID Maj_ID Co S_Degree 9999 07 1234 8888 05 5678 * Primary key can be either SID or Maj_ID_Co
  • 11. Example – One-to-One Relationship Set Condition SID Name 1:1 S/N # Relationship Student Have Laptop Major GPA Brand SID Name Major GPA LP_S/N Hav_Cond 9999 Bart Economy -4.0 123-456 Own 8888 Lisa Physics 4.0 567-890 Loan * Primary key can be either SID or LP_S/N
  • 12. Representing Relationship Set Unary/Binary Relationship • For one-to-many relationship w/out total participation – Same thing as one-to-one • For one-to-many/many-to-one relationship with one entity set having total participation on “many” side – Augment one extra column on the right side of the table of the entity set on the “many” side, put in there the primary key of the entity set on the “one” side as per to the relationship.
  • 13. Example – Many-to-One Relationship Set Semester SID Name N:1 SSN Relationship Student Advisor Professor Major GPA Dept Name SID Name Major GPA Pro_SSN Ad_Sem 9999 Bart Economy -4.0 123-456 Fall 2006 8888 Lisa Physics 4.0 567-890 Fall 2005 * Primary key of this table is SID
  • 14. Representing Relationship Set Unary/Binary Relationship • For many-to-many relationship – Same thing as one-to-one relationship without total participation. – Primary key of this new schema is the union of the foreign keys of both entity sets. – No augmentation approach possible…
  • 15. Representing Relationship Set N-ary Relationship • Intuitively Simple – Build a new table with as many columns as there are attributes for the union of the primary keys of all participating entity sets. – Augment additional columns for descriptive attributes of the relationship set (if necessary) – The primary key of this table is the union of all primary keys of entity sets that are on “many” side – That is it, we are done.
  • 16. Example – N-ary Relationship Set P-Key1 D-Attribute A-Key E-Set 1 P-Key2 A relationship Another Set E-Set 2 P-Key3 E-Set 3 P-Key1 P-Key2 P-Key3 A-Key D-Attribute 9999 8888 7777 6666 Yes 1234 5678 9012 3456 No * Primary key of this table is P-Key1 + P-Key2 + P-Key3
  • 17. Representing Relationship Set Identifying Relationship • This is what you have to know – You DON’T have to build a table/schema for the identifying relationship set once you have built a table/schema for the corresponding weak entity set – Reason: • A special case of one-to-many with total participation • Reduce Redundancy
  • 18. Representing Composite Attribute • Relational Model Indivisibility Rule Applies • One column for each component attribute • NO column for the composite attribute itself SSN Name SSN Name Street City Professor 9999 Dr. Smith 50 1st St. Fake City 8888 Dr. Lee 1 B St. San Jose Address Street City
  • 19. Representing Multivalue Attribute • For each multivalue attribute in an entity set/relationship set – Build a new relation schema with two columns – One column for the primary keys of the entity set/relationship set that has the multivalue attribute – Another column for the multivalue attributes. Each cell of this column holds only one value. So each value is represented as an unique tuple – Primary key for this schema is the union of all attributes
  • 20. Example – Multivalue attribute SID Name The primary key for this table is Student_SID + Children, the union of all Children attributes Student Major GPA Stud_SID Children 1234 Johnson 1234 Mary SID Name Major GPA 5678 Bart 1234 John CS 2.8 5678 Lisa 5678 Homer EE 3.6 5678 Maggie
  • 21. Representing Class Hierarchy • Two general approaches depending on disjointness and completeness – For non-disjoint and/or non-complete class hierarchy: • create a table for each super class entity set according to normal entity set translation method. • Create a table for each subclass entity set with a column for each of the attributes of that entity set plus one for each attributes of the primary key of the super class entity set • This primary key from super class entity set is also used as the primary key for this new table
  • 22. Example SSN Name Person SID Status Gender ISA Student Major GPA SSN Name Gender 1234 Homer Male 5678 Marge Female SSN SID Status Major GPA 1234 9999 Full CS 2.8 5678 8888 Part EE 3.6
  • 23. Representing Class Hierarchy • Two general approaches depending on disjointness and completeness – For disjoint AND complete mapping class hierarchy: – DO NOT create a table for the super class entity set – Create a table for each subclass entity set include all attributes of that subclass entity set and attributes of the superclass entity set – Simple and Intuitive enough, need example?
  • 24. SSN Name Example No table created for superclass entity set SJSU people ISA SID Student Faculty Disjoint and Complete mapping Major GPA Dept SSN Name SID Major GPA SSN Name Dept 1234 John 9999 CS 2.8 1234 Homer C.S. 5678 Mary 8888 EE 3.6 5678 Marge Math
  • 25. Representing Aggregation Name SSN Name Student Advisor Professor Dept SID Name member Primary Key of Advisor Dept SID Code Code 1234 04 Primary key of Dept 5678 08