Upload
willis-wood
View
219
Download
0
Embed Size (px)
Citation preview
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)
Multi-Value AttributesStaff
staffNo
. . .
qualifications : Composite (…)
: Multi-Value
wkExp : Composite (…)
: Multi-Value
. . .
Tables: Staff
Qualification
WorkExperience
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
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
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
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)
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)
Project – Phase III
Normalization
Notes: 14 – 18
Assignment 5, 6
Test 1
DBDL for final tables in BCNF.
Quiz 3
10
Comparing Dates
Insert into bookingValues('H01', 'G01011', SysDate, SysDate + 2, 'R103');
Select *From BookingWhere Date_From = SysDate;
-- no rows selected
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!
Schedule
• Phase IIIWednesday, May 1
• Quiz 4Wednesday, May 1
• Test 2Wednesday May 8
• Final ExamThursday, May 16, at 7 PM
13
Lab 10
14