0
How to translate ERModel to Relational       Model     By- Mr.Sanket Senapati          Mechanical RITAM Engg. College Raya...
Review - Concepts     Relational Model is made up of tables•   A row of table      = a relational instance/tuple•   A colu...
Review - Example                                              Attribute                                                   ...
From ER Model to Relational              Model  So… how do we convert an ER diagram into a               table?? Simple!!B...
Example – Strong Entity Set  SID           Name                         SSN           Name           Student              ...
Representation of Weak Entity Set• Weak Entity Set Cannot exists alone• To build a table/schema for weak entity set  – Con...
Example – Weak Entity Set                                                 Age SID           Name                          ...
Representation of Relationship Set       --This is a little more complicated-- Unary/Binary Relationship set    Depends ...
Representing Relationship Set            Unary/Binary Relationship• For one-to-one relationship w/out total participation ...
Example – One-to-One Relationship Set                                        Degree SID           Name                    ...
Example – One-to-One Relationship Set                                         Condition SID           Name       1:1      ...
Representing Relationship Set          Unary/Binary Relationship• For one-to-many relationship w/out total  participation ...
Example – Many-to-One Relationship Set                                           Semester SID             Name       N:1  ...
Representing Relationship Set          Unary/Binary Relationship• For many-to-many relationship   – Same thing as one-to-o...
Representing Relationship Set                 N-ary Relationship• Intuitively Simple   – Build a new table with as many co...
Example – N-ary Relationship SetP-Key1                                         D-Attribute              A-Key           E-...
Representing Relationship Set              Identifying Relationship• This is what you have to know  – You DON’T have to bu...
Representing Composite Attribute• Relational Model Indivisibility Rule Applies• One column for each component attribute• N...
Representing Multivalue Attribute• For each multivalue attribute in an entity  set/relationship set   – Build a new relati...
Example – Multivalue attribute SID             Name                              The primary key for this                 ...
Representing Class Hierarchy• Two general approaches depending on  disjointness and completeness  – For non-disjoint and/o...
Example             SSN           Name                                                             Person       SID       ...
Representing Class Hierarchy• Two general approaches depending on  disjointness and completeness  – For disjoint AND compl...
SSN         NameExample                                          No table created for                                     ...
Representing Aggregation           Name                           SSN                Name      Student                   A...
Finally, we are done
Applause??• Thank you…
Upcoming SlideShare
Loading in...5
×

E r model

252

Published on

E-R MODEL by Mr.SANKET SENAPATI>>>>>>>>>>>

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
252
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "E r model"

  1. 1. How to translate ERModel to Relational Model By- Mr.Sanket Senapati Mechanical RITAM Engg. College Rayagada.
  2. 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. 3. Review - Example Attribute Cardinality =tuple/relationalinstance SID Name Major GPA 1234 John CS 2.8 5678 Mary EE 3.6 2 4 Degree A Schema / Relation
  4. 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. 5. Example – Strong Entity Set SID Name SSN Name Student Advisor Professor Major Dept GPASID Name Major GPA SSN Name Dept1234 John CS 2.8 9999 Smith Math5678 Mary EE 3.6 8888 Lee CS
  6. 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. 7. Example – Weak Entity Set Age SID Name Name Student owns ChildrenMajor GPA Age Name Parent_SID 10 Bart 1234 8 Lisa 5678* Primary key of Children is Parent_SID + Name
  8. 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. 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. 10. Example – One-to-One Relationship Set Degree SID Name ID Code Student study MajorMajor GPA SID Maj_ID Co S_Degree 9999 07 1234 8888 05 5678* Primary key can be either SID or Maj_ID_Co
  11. 11. Example – One-to-One Relationship Set Condition SID Name 1:1 S/N # Relationship Student Have LaptopMajor 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. 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. 13. Example – Many-to-One Relationship Set Semester SID Name N:1 SSN Relationship Student Advisor ProfessorMajor 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. 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. 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. 16. Example – N-ary Relationship SetP-Key1 D-Attribute A-Key E-Set 1P-Key2 A relationship Another Set E-Set 2P-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. 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. 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. 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. 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 MarySID Name Major GPA 5678 Bart1234 John CS 2.8 5678 Lisa5678 Homer EE 3.6 5678 Maggie
  21. 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. 22. Example SSN Name Person SID Status Gender ISA Student Major GPA SSN Name Gender 1234 Homer Male 5678 Marge FemaleSSN SID Status Major GPA1234 9999 Full CS 2.85678 8888 Part EE 3.6
  23. 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. 24. SSN NameExample No table created for superclass entity set SJSU people ISA SID Student Faculty Disjoint and Complete mapping Major GPA DeptSSN Name SID Major GPA SSN Name Dept1234 John 9999 CS 2.8 1234 Homer C.S.5678 Mary 8888 EE 3.6 5678 Marge Math
  25. 25. Representing Aggregation Name SSN Name Student Advisor Professor Dept SID Name memberPrimary Key of Advisor Dept SID Code Code 1234 04 Primary key of Dept 5678 08
  26. 26. Finally, we are done
  27. 27. Applause??• Thank you…
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×