Nur S
2008-07-02 00:15:07 UTC
--------------------------------------------------------------------------------------------------------
Part 5 of the requirements contained in the file exercises15.txt You are also expected to have adjusted and tested your table creation, data loading and view creation scripts so that they comply with parts 1-4.
Question 1:
a) Produce a revised dataload script for the drop table and create table stages with key constraints.
Add to this dataload script, table insertions which are expected to be successful.
c) Run the dataload script to check that it works as expected.
d) Run the erroneous-data script shown below to check that all values contained are rejected. You may want to capture screen to show the error message generated.
e) With reference to tutorial exercises completed in week 2, add to the dataload script, code for creating appropriate views.
f) Produce two query script files for q8 and q10 respectively in exercises done in exercises 13.
g) All variable values in q8 should be input by user prompts.
All variable values in q10 should be input as parameters to the script.
---------------------------------------------------------------------------------------------
exercises15.txt
-------------------
/* drop tables in case exist already */
drop table vaccinations;
drop table valid_for;
drop table visits;
drop table doctor;
drop table patient;
/* create the base tables */
create table patient (
pid char(6) primary key not null,
pname char(20),
address varchar2(100),
dobirth date,
date_reg date);
create table doctor (
did char(1) primary key not null,
dname char(20),
date_start date);
create table visits (
pid char(6),
did char(1),
vdate date,
constraint pd_constraint primary key (pid,vdate),
constraint p_constraint foreign key (pid) references patient (pid),
constraint d_constraint foreign key (did) references doctor (did));
create table valid_for (
vaccinated char(20) primary key not null,
lasting_years number);
create table vaccinations (
pid char(6),
vdate date,
action number,
vaccinated char(20),
constraint vp_constraint primary key (pid,vdate,vaccinated),
constraint vv_constraint foreign key (vaccinated) references valid_for (vaccinated),
constraint pv_constraint foreign key (pid,vdate) references visits (pid,vdate));
/* partients see doctors at visits where they
receive vaccinations valid for a particular time */
insert into patient values('1','Fred','Newcastle','14-mar-1970','29-sep-2002');
insert into patient values('2','Mary','Heaton','28-oct-1983','06-aug-1991');
insert into patient values('3','Susan','Tynemouth','07-feb-1932','01-jan-1970');
insert into patient values('4','Bill','Gosforth','03-jan-1982','18-jul-1991');
insert into doctor values ('1','Peter Roberts','25-apr-1995');
insert into doctor values ('2','Brenda Townsend','06-sep-1998');
insert into visits values('1','1','04-dec-2002');
insert into visits values('2','2','06-aug-1991');
insert into visits values('2','2','04-mar-1994');
insert into visits values('2','2','27-jul-1997');
insert into visits values('2','2','16-dec-1999');
insert into visits values('4','1','22-jul-1991');
insert into visits values('4','1','26-jun-1993');
insert into visits values('4','2','30-jun-1993');
insert into visits values('4','2','09-jul-1997');
insert into visits values('4','1','30-jun-2002');
insert into valid_for values('smallpox',10);
insert into valid_for values('typhoid',3);
insert into valid_for values('cholera',0.5);
insert into valid_for values('polio',10);
insert into valid_for values('tetanus',7);
insert into valid_for values('hepatitis',0.5);
insert into vaccinations values('1','04-dec-2002',1,'smallpox');
insert into vaccinations values('1','04-dec-2002',2,'typhoid');
insert into vaccinations values('2','06-aug-1991',1,'typhoid');
insert into vaccinations values('2','06-aug-1991',2,'cholera');
insert into vaccinations values('2','06-aug-1991',3,'polio');
insert into vaccinations values('2','04-mar-1994',1,'typhoid');
insert into vaccinations values('2','27-jul-1997',1,'typhoid');
insert into vaccinations values('2','27-jul-1997',1,'tetanus');
insert into vaccinations values('2','16-dec-1999',1,'Typhoid');
insert into vaccinations values('2','16-dec-1999',1,'hepatitis');
insert into vaccinations values('4','22-jul-1991',1,'typhoid');
insert into vaccinations values('4','22-jul-1991',2,'cholera');
insert into vaccinations values('4','26-jun-1993',1,'tetanus');
insert into vaccinations values('4','30-jun-1993',1,'typhoid');
insert into vaccinations values('4','09-jul-1997',1,'typhoid');
insert into vaccinations values('4','09-jul-1997',2,'hepatitis');
insert into vaccinations values('4','30-jun-2002',1,'cholera');
insert into vaccinations values('4','30-jun-2002',1,'typhoid');
/* end of script */
THis is the another script file for dataloaderror.sql
/* These below should be rejected */
insert into patient values('3','Rachel','Tynemouth','14-feb-1982','31-jan-1990');
insert into doctor values ('1','Michael Smith','25-jul-1997');
insert into visits values('4','2','26-jun-1993');
insert into vaccinations values('4','30-jun-1993',1,'cholera');
insert into vaccinations values('4','30-jun-2002',2,'typhoid');
insert into valid_for values('cholera',0.5);
insert into visits values('2','5','17-dec-1999');
insert into visits values('19','2','16-dec-1999');
insert into vaccinations values('17','27-jul-1997',1,'typhoid');
insert into vaccinations values('2','28-jul-1997',1,'typhoid');
/* end of script */
<<<<<<<<<<<<<<<<<<
Three answers:
RINKY
2008-07-02 05:55:44 UTC
?
2016-11-09 16:40:54 UTC
wunti
2008-07-02 01:53:14 UTC
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.