Business Information Management - Data Management subject. Third part of Module 1 Relational Database. This document contains all the slides, notes from 2 students and extra information collected on Internet. I had a 15 out 20 for this subject.
Converting Entity-Relationship Diagrams to
Relational Databases
The Rules
- Each entity will convert to a table.
- Each many-to-many relationship or associative entity will convert to a table. (a middle
table) If you have at ERD level one book as many authors and many autor have many
books
- During the conversion, certain rules must be followed to ensure that foreign keys appear
in their proper places in the tables. (it’s about the primary and foreign keys, that’s what
the db understands)
ERD doesn’t have primary keys or foreign keys
Converting a Simple Entity
S a le s p e rs o n S a le s p e rs o n C o m m is s io n
N um ber N am e P e rc e n ta g e Y e a r o f H ire
SA LESPERSO N
The table simply contains the attributes that were specified in
the entity box.
Salesperson Number is underlined to indicate that it is the
unique identifier of the entity and the primary key of the table.
Converting Entities in
Binary Relationships:
One-to-One
There are three options for designing
tables to represent this data.
One-to-One: Option #1
The two entities are combined into one
relational table.
S a le s p e rs o n S a le s p e rs o n C o m m is s io n Y e a r O ffic e
N um ber N am e P e rc e n ta g e of N u m b e r T e le p h o n e S iz e
H ire
S A L E S P E R S O N /O F F IC E
One-to-One: Option #2 He prefers this one
Separate tables for the SALESPERSON and
OFFICE entities, with Office Number as a
foreign key in the SALESPERSON table.
1
,One-to-One: Option #3
Separate tables for the SALESPERSON and
OFFICE entities, with Salesperson Number as a
foreign key in the OFFICE table.
Converting Entities in Binary Relationships: One-to Many
The unique identifier of the entity
on the“one side”of the one-to-
many relationship is placed as a
foreign key in the table
representing the entity on the
“many side.”
So, the Salesperson Number
attribute is placed in the
CUSTOMER table as a foreign key.
Many sales persons selling
many products and may
products are sold by many
sales persons: many to
many relationship
They have no FK but only
PK
Converting Entities in Binary Relationships: Many-to Many
2
, Here is
presented as
entity
- E-R diagram with the many-to-many binary relationship and the equivalent diagram
using an associative entity.
Converting Entities in Binary Relationships: Many-to Many
- An E-R diagram with two entities in a many-to-many relationship converts to three
relational tables.
- Each of the two entities converts to a table with its own attributes but with no foreign
keys (regarding this relationship).
- In addition, there must be a third“many-to-many" table for the many-to-many
relationship.
Converting Entities in Unary Relationships: One-to-
One
• With only one entity type
involved and with a one-to-
one relationship, the
conversion requires only one
table.
3
One to one
S a le s p e rs o n S a le s p e rs o n C o m m is s io n B ackup relationship
N um ber N am e P e rc e n ta g e Y e a r o f H ire N um ber
SA LESPER SO N
, Converting Entities in Unary Relationships: One-to-
Many
• Very similar to the one- One sales person is
to-one unary case. managed by one
manager and one
manager manages
many sales
persons
S a le s p e rs o n S a le s p e rs o n C o m m is s io n
N um ber N am e P e rc e n ta g e Y e a r o f H ire M anager
SA LESPER SO N
Converting Entities in Unary Relationships: Many-to-
Many 7-14
P ro d u c t P ro d u c t
N um ber N am e U n it P ric e
PR O D U CT
P ro d u c t S u b -A s s e m b ly
N um ber N um ber Q u a n tity
C O M PO N EN T
• This relationship requires two tables in the conversion.
• The PRODUCT table has no foreign keys.
7-15
4
, Converting Entities in Unary Relationships: Many-to-
Many
P ro d u c t P ro d u c t
N um ber N am e U n it P ric e
PR O D U C T
P ro d u c t S u b -A s s e m b ly
N um ber N um ber Q u a n tity
CO M PO N EN T
• A second table is created since in the conversion of a
many-to-many relationship of any degree — unary, binary,
or ternary — the number of tables will be equal to the
number of entity types (one, two, or three, respectively)
plus one more table for the many-to-many relationship.
Converting Entities in 7-16
Ternary Relationships
S a le s p e rs o n S a le s p e rs o n C o m m is s io n
N um ber N am e P e rc e n ta g e Y e a r o f H ire
SA LESPER SO N
S a le s p e rs o n C u s to m e r P ro d u c t
N um ber N um ber N u m b e r D a te Q u a n tity
SA LE
P ro d u c t P ro d u c t
N um ber N am e U n it P ric e
PRO D U CT
• The primary key of the SALE
table is the combination of the C u s to m e r C u s to m e r
unique identifiers of the three N um ber N am e H Q C ity
entities involved, plus the Date C U STO M ER
attribute. 7-17
5
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller shafaqsara. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $4.31. You're not tied to anything after your purchase.