Introduction to Database Systems Mapping ER Models to ..., Study notes of Design

We cannot store date in an ER schema ... ER schemas to relational schemas ... Every atomic attribute of the entity type becomes a relation attribute.

Typology: Study notes

2021/2022

Uploaded on 09/07/2022

nabeel_kk
nabeel_kk šŸ‡øšŸ‡¦

4.6

(65)

1.3K documents

1 / 39

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Introduction to
Database Systems
Mapping ER Models to
Relational Schemas
Werner Nutt
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27

Partial preview of the text

Download Introduction to Database Systems Mapping ER Models to ... and more Study notes Design in PDF only on Docsity!

Introduction toDatabase Systems Mapping ER Models toRelational SchemasWerner Nutt

Conceptual and Logical Design

Conceptual Model: Relational Model:

PERSON BUYS namePRODUCTprice^

name^

ssn

Translation: Principles

-^ Maps– ER schemas to relational schemas– ER instances to relational instances•^ Ideally, the mapping should– be one-to-one in both directions– not lose any information•^ Difficulties:– what to do with ER-instances that have identical

attribute values, but consist of different entities?– in which way do we want to preserve information?

Mapping Entity Types to Relations• For every

entity type

create a

relation

-^ Every

atomic attribute

of the entity type becomes a

relation attribute

-^ Composite attributes

: include

all the atomic attributes

-^ Derived attributes

are not included(but remember their

derivation rules

-^ Relation instances are subsets of the cross productof the domains of the attributes•^ Attributes of the

entity key

make up the

primary key

of the relation

given^ familynameSTUDENTstudno

no. ofstudents^

equip courseno COURSEsubject

Mapping Many:many Relationship Types

to Relations

Create a relation with the following set of attributes:

N^ (degree of relationship) U^ primary_key(E

)^ U^ i

{a,…,a^1

}M

i=

primary keys of eachentity type participatingin the relationship

attributes of therelationship type (if any)

labmarkENROLLED^ exammark given^ familynameSTUDENTstudno

no. ofstudents^

equip courseno COURSEsubject

Mapping Many:many Relationship Types

to Relations (cntd.)

ENROL(studno, courseno, labmark, exammark)Foreign Key ENROL(studno) references STUDENT(studno)Foreign Key ENROL(courseno) references COURSE(courseno)

labmarkENROLLEDexammark familygiven (^) nameSTUDENTstudno

no. ofstudents^

equip courseno COURSEsubject

Mapping Many:one Relationship Types

to Relations: Example

slot TUTOR

given^ familyname STUDENT studno

name STAFF

roomno

m^

1

The relationSTUDENT(studno, givenname, familyname)is extended toSTUDENT(studno, givenname, familyname, tutor, roomno, slot)and the constraintForeign Key STUDENT(tutor,roomno) references STAFF(name,roomno)

Mapping Many:one Relationship Types

to Relations (cntd.)

STAFFname

roomno kahn^

IT

bush^

goble^

zobel^

watson

IT

woods^

IT

capon^

A

lindsey

barringer

STUDENTstudno

given

family

tutor

roomno

slot

s^

fred^

jones^

bush^

2.^

12B

s^

mary^

brown^

kahn^

IT^

12B

s^

sue^

smith^

goble^

2.^

10A

s^

fred^

bloggs^

goble^

2.^

11A

s^

peter^

jones^

zobel^

2.^

13B

s^

jill^

peters^

kahn^

IT^

12A

Mapping Many:one Relationship Types

to Relations (cntd.)

TUTOR(studno, staffname, rommno, slot)and Foreign key TUTOR(studno) references STUDENT(studno)Foreign key TUTOR(staffname, roomno) references

Compare with themapping of many:manyrelationship types!STAFF(name, roomno) slot TUTOR

given^ familyname STUDENT studno

name STAFF

roomno

m^

1

STUDENTstudno given

family s^

fred^

jones s^

mary^

brown s^

sue^

smith s^

fred^

bloggs s^

peter^

jones s^

jill^

peters

STAFFname^

roomno kahn^

IT

bush^

goble^

zobel^

watson

IT

woods^

IT

capon^

A

lindsey

barringer

TUTORstudno

tutor^

roomno

slot

s^

bush^

2.^

12B

s^

kahn^

IT^

12B

s^

goble^

2.^

10A

s^

goble^

2.^

11A

s^

zobel^

2.^

13B

s^

kahn^

IT^

12A

Mapping

Many:one

Relationship Types

to Relations (cntd.)

Optional Participation of the

Determined Entity

STUDENTstudno

given

family

hons

s^

fred^

jones^

ca

s^

mary^

brown^

cis

s^

sue^

smith^

cs

s^

fred^

bloggs

ca

s^

peter^

jones^

cs

s^

jill^

peters^

ca

SCHOOLhons^

faculty ac^

accountancy is^

information systems cs^

computer science ce^

computer science mi^

medicine ma^

mathematics

ā€œhonsā€ cannot be NULL becauseit is mandatory for a student tobe registered for a school^ Ǝ^ ā€œnot nullā€ constraintNo student is registered for ā€œmiā€,so ā€œmiā€ doesn’t occuras a foreign key value

(but that’s no problem)

Optional Participation of theDeterminant Entity (ā€˜many end’)

slot TUTOR

given^ familyname STUDENT studno

name STAFF

roomno

m^

1

A student entity instance need not

participate in a relationship instance of TUTOR

A staff entity instance

must participate in a relationshipinstance of

TUTOR

Optional Participation of theDeterminant Entity (cntd.)

STAFFname

roomno kahn^

IT

bush^

goble^

zobel^

watson

IT

woods^

IT

capon^

A

lindsey

barringer

STUDENTstudno

given

family

tutor

roomno

slot

s^

fred^

jones^

bush^

2.^

12B

s^

mary^

brown^

kahn^

IT^

12B

s^

sue^

smith^

goble^

2.^

10A

s^

fred^

bloggs^

goble^

2.^

11A

s^

peter^

jones^

zobel^

2.^

13B

s^

jill^

peters^

kahn^

IT^

12A

Optional Participation of theDeterminant Entity (cntd.)

STAFFname

roomno kahn^

IT

bush^

goble^

zobel^

watson

IT

woods^

IT

capon^

A

lindsey

barringer

STUDENTstudno

given

family

tutor

roomno

slot

s^

fred^

jones^

bush^

2.^

12B

s^

mary^

brown^

kahn^

IT^

12B

s^

sue^

smith^

goble^

2.^

10A

s^

fred^

bloggs^

goble^

2.^

11A

s^

peter^

jones^

NULL^

NULL^

NULL

s^

jill^

peters^

kahn^

IT^

12A