Presentation is loading. Please wait.

Presentation is loading. Please wait.

IS 230Lecture 4Slide 1 Entity Relationship to Relational Model Mapping Lecture 5.

Similar presentations


Presentation on theme: "IS 230Lecture 4Slide 1 Entity Relationship to Relational Model Mapping Lecture 5."— Presentation transcript:

1 IS 230Lecture 4Slide 1 Entity Relationship to Relational Model Mapping Lecture 5

2 IS 230Lecture 4Slide 2 Relational Model  Structure of Relational Databases  Relation schema  Instances  keys  Translation of ER-model into Relational Model

3 IS 230Lecture 4Slide 3 1. Reduction of an E-R Schema to Tables Primary keys allow entities, relationships, and multiple attributes to be expressed uniformly as tables which represent the contents of the database. A database which conforms to an E­R diagram can be represented by a collection of tables. For each entity set and relationship set there is a unique table which is assigned the name of the corresponding entity set or relationship set. Each table has a number of columns (generally corresponding to attributes), which have unique names. Converting an E­R diagram to a table format is the basis for deriving a relational database design from an E­R diagram.

4 IS 230Lecture 4Slide 4 1.1. Representing entity sets as tables A strong entity set reduces to a table with the same attributes. A weak entity set becomes a table that includes a column for the primary key of the identifying strong entity set. social-securityc-street 321-12-3123 019-28-3746 677-89-9011 Main North Main c-city Harrison Rye Harrison customer-name Jones Smith Hayes The customer table payment-numberpayment-date 5 11 22 10 May 1996 17 May 1996 23 May 1996 payment-amount 50 75 300 loan-number L-17 L-23 L-15 The payment table

5 IS 230Lecture 4Slide 5 1.2. Representing entity sets as tables A many­to­many relationship set is represented as a table with columns for the primary keys of the two participating entity sets, and any descriptive attributes of the relationship set. The table corresponding to a relationship set linking a weak entity set to its identifying strong entity set is redundant. The payment table already contains the information that would appear in the loan­payment table (i.e., the columns loan­number and payment­number). social-securityaccount-numberaccess-date The depositor table … … …

6 IS 230Lecture 4Slide 6 1.3. Determining Keys from E-R Sets Strong entity set. The primary key of the entity set becomes the primary key of the relation. Weak entity set. The primary key of the relation consists of the union of the primary key of the strong entity set and the discriminator of the weak entity set. Relationship set. The union of the primary keys of the related entity sets becomes a super key of the relation. For binary many-to-one relationship sets, the primary key of the “many” entity set becomes the relation’s primary key. For one-to-one relationship sets, the relation’s primary key can be that of either entity set. For many-to-many relationship sets, the union of the primary keys becomes the relation’s primary key

7 IS 230Lecture 4Slide 7 1.4. Multivalued attributes An entity with a multivalued attribute gives an additional table, whose attributes are the multivalued attribute plus the primary key for the entity. The primary key for the relation is that of the entity or relationship set which has the attribute, along with the column holding individual values of the multivalued attributed. dependent-name Harrison Ford Bentsson Ford e-social-security 321­12­3123 019­28­3746 677­89­9011 The dependent table

8 IS 230Lecture 4Slide 8

9 IS 230Lecture 4Slide 9 Employee ERD DNUMBERDNAME RELATIONSHIPBDATESEXDEPENDENT_NAME DEPENDENT WORKS_ON PROJECT DEPT_LOCATIONS SUPERSSN MGRSTARTDATEMGRSSN DLOCATIONDNUMBER PLOCATIONPNUMBERPNAMEDNUM ESSN HOURS PNO ESSN SALARYSEXADDRESSBDATESSNLNAMEMINITFNAME EMPLOYEE DNO DEPARTMENT


Download ppt "IS 230Lecture 4Slide 1 Entity Relationship to Relational Model Mapping Lecture 5."

Similar presentations


Ads by Google