How to convert ER diagrams into relation schemas

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 13

flashcard set

Earn XP

Description and Tags

flashcards made from Relational Model slide pages 23-end from week 4

14 Terms

1

How to convert ER diagrams into relation schemas?

-A database which conforms to an E-R diagram can be represented by a collection of relation schemas.

-For each entity-set and each relationship-set in the E-R diagram there is a unique relation (table) schema that is assigned the name of the corresponding entity-set or relationship-set.

-Constraints arising from E-R design can be mapped to constraints on relation schemas.

New cards
2
<p>Strong entity sets</p>

Strong entity sets

Let E be a strong entity set with attributes a1, a2, …, an.

Representation: we represent this entity by a relation scheme called E with n distinct attributes.

Each tuple in a relation on this schema corresponds to one entity of the entity set E.

Primary Key: the primary key of the entity set serves as the primary key of the resulting schema.

New cards
3
<p>weak entity sets</p>

weak entity sets

A: a weak entity set with attributes a1, a2,…, am.

B: a strong entity set on which A depends.

b1, …, bn : the primary key of B.

Representation: We represent the entity set A by a relation schema A with the following attributes:

  {a1, a2,…, am } U { b1, …, bn }

Primary key: primary key of the strong entity set together with the partial-key of the weak entity set.

Foreign Key Constraints: We also have a foreign key constraint on relation A specifying that the attributes b1, …, bn reference the primary key of B

New cards
4
<p>relationship sets</p>

relationship sets

Simply build a table where attributes are the primary keys of each of the participating entities!

(and any attributes of the relationship)


R: a relationship set.

a1, a2, …, am : set of attributes formed by the union of the primary keys of each entity set participating in R,

•Descriptive attributes of R: b1, b2, …, bn (if any).

Representation: a relation schema called R with one attribute for:

   {a1, a2,…, am} U {b1, …, bn}

New cards
5

relationship sets- primary keys

Binary many-to-many relationship: the union of the primary key attributes from the participating entity sets becomes the primary key

Binary one-to-one relationship: the primary key of either entity set can be chosen as the primary key for the relationship

New cards
6

relationship sets- primary keys part 2

Binary many-to-one or one-to-many relationship: the primary key of the entity set on the “many” side of the relationship set serves as the primary key

N-ary relationships without arrows: the union of the primary key attributes from the participating entity sets becomes the primary key

N-ary relationships with one arrow: the primary keys of the entity sets not on the “arrow side” of the relationship set serve as the primary key for the schema.

New cards
7

relationship sets- foreign key constraints

•In ER diagram: E1,…,Ek participates in relationship-set R

•Then, create a foreign key constraint from table-schema R with:

•Each primary-key in R (that was derived from primary-key of Ei) referencing the primary-key of the table-schema for Ei.

Simply reference all the primary-keys you took to their original table!

New cards
8

Combination of schemas

knowt flashcard image
New cards
9
<p><span>Combination of Schemas: one-to-one</span></p>

Combination of Schemas: one-to-one

•The schema for the relationship set linking a weak entity-set to its corresponding strong entity set is redundant (i.e., can be discarded)

•Why?? Because we already have the primary key of loan and the partial key of payment in the schema for Payment!

<p><span>•The schema for the relationship set linking a <strong>weak</strong> entity-set to its corresponding strong entity set is redundant (i.e., can be discarded)</span></p><p><span>•Why?? Because we already have the primary key of loan and the partial key of payment in the schema for Payment!</span></p>
New cards
10
<p><span>Combination of Schemas: many-to-one</span></p>

Combination of Schemas: many-to-one

knowt flashcard image
New cards
11

Composite attributes

•Composite attributes are “flattened out” by creating a separate attribute for each component attribute

Example: given entity set customer with composite attribute name with component attributes first_name and last_name the schema corresponding to the entity set has two attributes

        name.first_name  and name.last_name

New cards
12

Multi-valued Attributes + example

•Each multi-valued attribute M of an entity E is represented by a new separate schema EM.

EM has attributes corresponding to the primary key of E and an attribute corresponding to multivalued attribute M

  Example:  Multi-valued attribute dependent_names entity  employee:
    employee_dependent_names = ( employee_id, d_name)

  Each value of the multivalued attribute maps to separate tuples EM

  Example: employee entity with primary key 103 and dependents Jack and Jane maps to two tuples:  
   (103 , Jack) and (103 , Jane)

Primary key of EM: we create a primary key of the relation schema consisting of all attributes of the schema.

<p><span>•Each multi-valued attribute <em>M</em> of an entity <em>E</em> is represented by <strong>a new separate schema</strong> <em>EM</em>.</span></p><p><span>•<em>EM</em> has attributes corresponding to the <strong>primary key </strong>of <em>E</em> and an attribute corresponding to multivalued attribute <em>M</em></span></p><p><span><strong>&nbsp; Example</strong>:&nbsp; Multi-valued attribute <em>dependent_names</em> entity&nbsp; <em>employee</em>:<br>&nbsp;&nbsp;&nbsp; <em>employee_dependent_names = </em>(<em> employee_id, d_name)</em></span></p><p><span>&nbsp; Each value of the multivalued attribute maps to <strong>separate</strong> tuples <em>EM</em></span></p><p><span>&nbsp; <strong>Example</strong>: employee entity with primary key <em>103</em> and dependents Jack and Jane maps to <strong>two </strong>tuples:&nbsp;&nbsp; <br>&nbsp;&nbsp; (<em>103</em> , <em>Jack</em>) and (<em>103</em> , <em>Jane</em>)</span></p><p><span><strong>Primary key of EM</strong>: we create a primary key of the relation schema consisting of <strong>all</strong> attributes of the schema.</span></p>
New cards
13

Sub-classes method 1 + example

Method 1

•Form a schema for the higher-level entity-set

•Form a schema for each lower-level entity-set, that includes:

•primary key of higher-level entity set; and

•local attributes.

The primary key attributes of the higher level entity set become primary key attributes of both higher level and lower level entity sets.

Example:      
     person = (person_id, street, city)
     customer = (person_id, credit_rating)
     employee = (person_id, salary)

<p><strong><u>Method 1</u></strong></p><p>•Form a schema for the <strong>higher-level</strong> entity-set</p><p>•Form a schema for <strong>each lower-level </strong>entity-set, that includes:</p><p>•primary key of higher-level entity set; and</p><p>•local attributes.</p><p>The primary key attributes of the higher level entity set become primary key attributes of both higher level and lower level entity sets.</p><p><strong>Example</strong>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp; <em>person = (<u>person_id</u>, street, city) <br>&nbsp;&nbsp;&nbsp;&nbsp; customer = (<u>person_id</u>, credit_rating)<br>&nbsp;&nbsp;&nbsp;&nbsp; employee = (<u>person_id</u>, salary)</em></p>
New cards
14

Sub-classes method 2

Method 2: only in case sub-classes are disjoint and total

•For each lower level entity set create a schema that includes an attribute for each of the attributes of that entity set plus one for each attribute of the higher level entity set. Don’t create schema for higher-level entity

•Example:

employee = (person_id, name, street, city, salary)

customer = (person_id, name, street, city, credit_rating)

Drawback: if there is a relationship set involving the higher level entity set, we do not have a single table to which a foreign key constraint can refer.

New cards

Explore top notes

note Note
studied byStudied by 1 person
86 days ago
5.0(1)
note Note
studied byStudied by 14 people
761 days ago
5.0(2)
note Note
studied byStudied by 66 people
511 days ago
5.0(1)
note Note
studied byStudied by 14 people
953 days ago
5.0(1)
note Note
studied byStudied by 5 people
926 days ago
4.0(1)
note Note
studied byStudied by 10 people
895 days ago
5.0(1)
note Note
studied byStudied by 11 people
972 days ago
4.5(2)
note Note
studied byStudied by 5237 people
150 days ago
4.4(9)

Explore top flashcards

flashcards Flashcard (28)
studied byStudied by 7 people
662 days ago
5.0(1)
flashcards Flashcard (96)
studied byStudied by 73 people
748 days ago
5.0(5)
flashcards Flashcard (43)
studied byStudied by 3 people
635 days ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 8 people
789 days ago
5.0(1)
flashcards Flashcard (170)
studied byStudied by 7 people
121 days ago
5.0(1)
flashcards Flashcard (32)
studied byStudied by 41 people
97 days ago
5.0(1)
flashcards Flashcard (1000)
studied byStudied by 29 people
852 days ago
4.0(1)
flashcards Flashcard (53)
studied byStudied by 3742 people
709 days ago
4.2(54)
robot