drop table WorkerHasSkill;
drop table Skill;
drop table Ledger;
drop table Person;
drop table Lodging;
drop sequence LedgerSequence;
drop type WorkerHasSkill_TP;
drop type Skill_TP;
drop type Ledger_TP;
drop type Person_TP;
drop type Lodging_TP;
drop type Address_TP;
create sequence LedgerSequence;
create type Address_TP AS OBJECT (
Street1 varchar2(100),
Street2 varchar2(100),
City varchar2(100),
State varchar2(2),
PostalCode varchar2(15),
Country varchar2(50)
);
/
create type Lodging_TP as OBJECT (
Lodging varchar2(15),
LongName varchar2(40),
Manager varchar2(25),
Address Address_TP
);
/
create type Person_TP as OBJECT (
Name varchar2(25),
Age NUMBER,
Lodging REF Lodging_TP
);
/
create type Ledger_TP as OBJECT (
LedgerID number,
ActionDate date,
Action varchar2(8),
Item varchar2(30),
Quantity number,
QuantityType varchar2(10),
Rate number(9,2),
Amount number(9,2),
Person REF Person_TP
);
/
create type Skill_TP as OBJECT (
Skill varchar2(25),
Description varchar2(80)
);
/
rem Note that you cannot have a REF attribute as part of the primary key
create type WorkerHasSkill_TP as OBJECT (
Name varchar2(25),
Skill varchar2(25),
Ability varchar2(15)
);
/
create table Ledger of Ledger_TP(
primary key (LedgerID)
);
create table Lodging of Lodging_TP(
primary key (Lodging)
);
create table Skill of Skill_TP (
primary key (Skill)
);
create table Person of Person_TP (
primary key (Name)
);
create table WorkerHasSkill of WorkerHasSkill_TP (
primary key (Name,Skill),
foreign key (Name) references Person(Name),
foreign key (Skill) references Skill(Skill)
);
--------Lodging table-------
insert into Lodging values (
'Cranmer','Cranmer Retreat House','Thom Cranmer',
Address_TP('Hill St.',null,'Berkeley','NH','03431','USA'));
insert into Lodging values (
'Matts','Matts Long Bunk House','Roland Brandt',
Address_TP('3 Mile RD.',null,'Keene','NH','03431','USA'));
insert into Lodging values (
'Mullers','Mullers Coed Lodging','Ken Muller',
Address_TP('120 Main.',null,'Edmeston','NH','03431','USA'));
insert into Lodging values (
'Papa King','Papa King Rooming','William King',
Address_TP('127 Main',null,'Edmeston','NH','03431','USA'));
insert into Lodging values (
'Rose Hill','Rose Hill for Men','John Peletier',
Address_TP('RFD 3',null,'N. Edmeston','NH','03431','USA'));
insert into Lodging values (
'Weitbrocht','Weitbrocht Rooming','Eunice Benson',
Address_TP('320 Geneva',null,'Keene','NH','03431','USA'));
--------Skill table------
insert into Skill values ('Woodcutter','Mark And Fell Trees,Split,Stack,Haul');
insert into Skill values ('Combine Driver','Harness, Drive,Groom Horser,Adjust Blades');
insert into Skill values ('Smithy','Stack For Fire,Run Bellows,Cut,Shoe Horses');
insert into Skill values ('Grave Digger','Mard And Cut Sod,Dig,Shore,Filll,Resod');
insert into Skill values ('Discus','Harness,Drive,Groom Horses,Blade Depth');
insert into Skill values ('Work','General Unskilled Labor');
-------Person table------
insert into Person
select 'Bart Sarjeant',22,REF(L)
from Lodging L
where Lodging = 'Cranmer';
insert into Person
select 'Elbert Talbot',43,REF(L)
from Lodging L
where Lodging = 'Weitbrocht';
insert into Person
select 'Donald Rollo',16,REF(L)
from Lodging L
where Lodging = 'Matts';
insert into Person
select 'Jed Hopkins',33,REF(L)
from Lodging L
where Lodging = 'Matts';
insert into Person
select 'William Swing',15,REF(L)
from Lodging L
where Lodging = 'Cranmer';
insert into Person
select 'John Pearson',27,REF(L)
from Lodging L
where Lodging = 'Rose Hill';
insert into Person
select 'George Oscar',41,REF(L)
from Lodging L
where Lodging = 'Rose Hill';
insert into Person
select 'Kay And Palmer Wallbom',null,REF(L)
from Lodging L
where Lodging = 'Rose Hill';
insert into Person
select 'Pat Lavay',21,REF(L)
from Lodging L
where Lodging = 'Rose Hill';
insert into Person
select 'Richard Koch And Brothers',null,REF(L)
from Lodging L
where Lodging = 'Weitbrocht';
insert into Person
select 'Dick Jones',18,REF(L)
from Lodging L
where Lodging = 'Rose Hill';
insert into Person
select 'Adah Talbot',23,REF(L)
from Lodging L
where Lodging = 'Papa King';
insert into Person
select 'Roland Brandt',35,REF(L)
from Lodging L
where Lodging = 'Matts';
insert into Person
select 'Peter Lawson',25,REF(L)
from Lodging L
where Lodging = 'Cranmer';
insert into Person
select 'Victoria Lynn',32,REF(L)
from Lodging L
where Lodging = 'Mullers';
insert into Person values ('Wilfred Lowell',67,null);
insert into Person values ('Helen Brandt',15,null);
insert into Person
select 'Gerhardt Kentgen',55,REF(L)
from Lodging L
where Lodging = 'Papa King';
insert into Person
select 'Andrew Dye',29,REF(L)
from Lodging L
where Lodging = 'Rose Hill';
insert into Person values ('Blacksmith',null,null);
insert into Person values ('Boole And Jones',null,null);
insert into Person values ('Dean Foreman',null,null);
insert into Person values ('Dr. Carlstrom',null,null);
insert into Person values ('Edward Johnson',null,null);
insert into Person values ('Edythe Gammiere',null,null);
insert into Person values ('Feed Store',null,null);
insert into Person values ('Fred Fuller',null,null);
insert into Person values ('Gary Kentgen',null,null);
insert into Person values ('General Store',null,null);
insert into Person values ('George August',null,null);
insert into Person values ('George B. McCormick',null,null);
insert into Person values ('Harold Schole',null,null);
insert into Person values ('Henry Chase',null,null);
insert into Person values ('Isaiah James',null,null);
insert into Person values ('James Cole',null,null);
insert into Person values ('Janice Talbot',null,null);
insert into Person values ('John Austin',null,null);
insert into Person values ('Lily Carlstrom',null,null);
insert into Person values ('Livery',null,null);
insert into Person values ('Mill',null,null);
insert into Person values ('Manner Jewelers',null,null);
insert into Person values ('Methodist Church',null,null);
insert into Person values ('Morris Arnold',null,null);
insert into Person values ('Palmer Wallbom',null,null);
insert into Person values ('Phone Company',null,null);
insert into Person values ('Post Office',null,null);
insert into Person values ('Quarry',null,null);
insert into Person values ('Robert James',null,null);
insert into Person values ('Sam Dye',null,null);
insert into Person values ('School',null,null);
insert into Person values ('Underwood Bros',null,null);
insert into Person values ('Verna Hardware',null,null);
------WorkerHasSkill table-----
insert into WorkerHasSkill values ('Dick Jones','Smithy','Excellent');
insert into WorkerHasSkill values ('John Pearson','Combine Driver',null);
insert into WorkerHasSkill values ('John Pearson','Smithy','Average');
insert into WorkerHasSkill values ('Helen Brandt','Combine Driver','Very Fast');
insert into WorkerHasSkill values ('John Pearson','Woodcutter','Good');
insert into WorkerHasSkill values ('Victoria Lynn','Smithy','Precise');
insert into WorkerHasSkill values ('Adah Talbot','Work','Good');
insert into WorkerHasSkill values ('Wilfred Lowell','Work','Average');
insert into WorkerHasSkill values ('Elbert Talbot','Discus','Slow');
insert into WorkerHasSkill values ('Wilfred Lowell','Discus','Average');
------Ledger table------
insert into Ledger
select LedgerSequence.NEXTVAL,'01-APR-01','Paid','Plowing',1,'Day',3,3,REF(P)
from Person P
where Name = 'Richard Koch And Brothers';
insert into Ledger
select LedgerSequence.NEXTVAL,'02-MAY-01','Paid','Work',1,'Day',1,1,REF(P)
from Person P
where Name = 'D