14
Project – Phase II Derive Database Schema from E-R Model DBDL

Project – Phase II Derive Database Schema from E-R Model DBDL

Embed Size (px)

Citation preview

Page 1: Project – Phase II Derive Database Schema from E-R Model DBDL

Project – Phase II

Derive Database Schema from E-R Model

DBDL

Page 2: Project – Phase II Derive Database Schema from E-R Model DBDL

E-R Model to DBDL

Entity Type Table

Composite: Use individual fields

Multi-Value: Separate table

Relationship Type Table or No Table

Many-to-Many: Separate table

One-to-Many: No new table

Copy PK as FK (one direction)

One-to-One: No new table

Copy PK as FK (either direction)

Page 3: Project – Phase II Derive Database Schema from E-R Model DBDL

Multi-Value AttributesStaff

staffNo

. . .

qualifications : Composite (…)

: Multi-Value

wkExp : Composite (…)

: Multi-Value

. . .

Tables: Staff

Qualification

WorkExperience

Page 4: Project – Phase II Derive Database Schema from E-R Model DBDL

Many-to-Many Relationship

Supply (1..*) Has (1..*) Supplier

One supply can come from multiple suppliersOne supplier can provide multiple

supplies

Tables: Supply

Supplier

SupplyFromSupplier

Page 5: Project – Phase II Derive Database Schema from E-R Model DBDL

Foreign Keys

Primary key of another table

Medication (patNo, fName, lName, wardNo, drugNo, drugName, unitsPerDay, adminMethod, startDate, finishDate, staffNo)

Primary Key : patNo, drugNo, startDate

Alternate Key : patNo, drugNo, finishDate

Foreign Key : patNo references Patient

wardNo references Ward

staffNo references Staff.

drugNo references Pharmaceutical

Page 6: Project – Phase II Derive Database Schema from E-R Model DBDL

Foreign Keys

Appointment (1..*) GettingInfoFrom (1) LocalDoctor

Appointment (apptNo, patNo, firstName, lastName, consultantNo, date, time, room, comment, docNo, clinicNo, clinicPhone)

Primary Key : apptNo

Alternate Key : consultantNo, date, time

patNo, date, time

Foreign Key : consultantNo references Staff(staffNo)

patNo references Patient

docNo references LocalDoctor

Page 7: Project – Phase II Derive Database Schema from E-R Model DBDL

Foreign Keys

InPatient (0..1) Has (1) Appointment

InPatient (patNo, patName, dateOnWaitList, wardReq, expectedStay, dateInWard, actDateDepart, bedNo, examApt)

Primary Key : patNo, dateOnWaitList

Alternate Key : none

Foreign Key : patNo references Patient

wardReq references Ward(wardNo)

examApt references Appointment(apptNo)

Page 8: Project – Phase II Derive Database Schema from E-R Model DBDL

Foreign Keys

OutPatient (0..1) Has (1) Appointment

OutPatient (patNo, fName, lName, address, phone, DOB, gender, appDate, appTime, examApt)

Primary Key : patNo, appDate

Alternate Key : none

Foreign Key : patNo references Patient

examApt references Appointment(apptNo)

Page 9: Project – Phase II Derive Database Schema from E-R Model DBDL

Project – Phase III

Normalization

Notes: 14 – 18

Assignment 5, 6

Test 1

DBDL for final tables in BCNF.

Page 10: Project – Phase II Derive Database Schema from E-R Model DBDL

Quiz 3

10

Page 11: Project – Phase II Derive Database Schema from E-R Model DBDL

Comparing Dates

Insert into bookingValues('H01', 'G01011', SysDate, SysDate + 2, 'R103');

Select *From BookingWhere Date_From = SysDate;

-- no rows selected

Page 12: Project – Phase II Derive Database Schema from E-R Model DBDL

Comparing Dates

Insert into bookingValues('H01', 'G01011', SysDate, SysDate + 2, 'R103');

Select *From BookingWhere Date_From = SysDate;

Select *From BookingWhere to_char(Date_From, 'dd mm yyyy') =

to_char(SysDate, 'dd mm yyyy');

-- one row selected-- Date has time inside!

Page 13: Project – Phase II Derive Database Schema from E-R Model DBDL

Schedule

• Phase IIIWednesday, May 1

• Quiz 4Wednesday, May 1

• Test 2Wednesday May 8

• Final ExamThursday, May 16, at 7 PM

13

Page 14: Project – Phase II Derive Database Schema from E-R Model DBDL

Lab 10

14