SlideShare a Scribd company logo
1 of 25
Download to read offline
The resto txt:
/* Use for TM254 2021J, TMA02, Question 6 Copyright 2021 The Open University */
/* Note - all dates are in 'YYYY-MM-DD' format */
/* This overrides the date format set by the local PC locale variable. */
GRANT USAGE ON SCHEMA public TO PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;
/* Evaluate/Run this file in the default database, postgres, and as the*/
/* default user, postgres. */
/* If you re-run the file you will reset any changes you have made to */
/* the database content back to the original content. */
/* The DROP IF EXISTS ensures that when you re-run the script file it */
/* replaces the content of the database, on first run the tables and */
/* domains don't exist so are not dropped and you recieve a warning */
/* message. */
DROP VIEW IF EXISTS Catalogue CASCADE;
DROP TABLE IF EXISTS TaskTicket CASCADE;
DROP TABLE IF EXISTS HasExpertiseIn CASCADE;
DROP TABLE IF EXISTS RestorationItem CASCADE;
DROP TABLE IF EXISTS Expert CASCADE;
DROP TABLE IF EXISTS Specialism CASCADE;
DROP DOMAIN IF EXISTS ItemCodes;
DROP DOMAIN IF EXISTS DescriptionString;
DROP DOMAIN IF EXISTS TaskNumbers;
DROP DOMAIN IF EXISTS NameString;
DROP DOMAIN IF EXISTS AddressString;
DROP DOMAIN IF EXISTS PublicityString;
DROP DOMAIN IF EXISTS EmailString;
DROP DOMAIN IF EXISTS YN;
DROP DOMAIN IF EXISTS SpecialismString;
DROP DOMAIN IF EXISTS QualificationsString;
DROP DOMAIN IF EXISTS MonetaryValues;
/* Now creating the domains */
CREATE DOMAIN ItemCodes AS INTEGER CHECK(VALUE > 0);
CREATE DOMAIN DescriptionString AS VARCHAR(120);
CREATE DOMAIN TaskNumbers AS INTEGER CHECK(VALUE > 0);
CREATE DOMAIN NameString AS VARCHAR(120);
CREATE DOMAIN AddressString AS VARCHAR(400);
CREATE DOMAIN PublicityString AS VARCHAR(120);
CREATE DOMAIN EmailString AS VARCHAR(100) CHECK (VALUE LIKE ('%@%'));
CREATE DOMAIN YN AS CHAR(1) CHECK(VALUE IN ('Y','N') );
CREATE DOMAIN SpecialismString AS VARCHAR(120);
CREATE DOMAIN QualificationsString AS VARCHAR(300);
CREATE DOMAIN MonetaryValues AS NUMERIC(9,2) CHECK (VALUE >= 0.00);
/* DOMAINS CREATED */
/* now creating tables */
CREATE TABLE Specialism(
Name SpecialismString PRIMARY KEY
);
CREATE TABLE RestorationItem(
ItemCode ItemCodes PRIMARY KEY,
ItemDescription DescriptionString NOT NULL,
WorkDescription DescriptionString NOT NULL,
InsuranceValue MonetaryValues,
CostEstimate MonetaryValues NOT NULL,
DateAccepted DATE NOT NULL,
DateReturned DATE,
PriceCharged MonetaryValues,
-- relationship Requires mandatory participation
-- WARNING - the requires mandatory participation
-- constraint has not been implemented.
-- This omission permits the entry of a row that
-- does not match a related TaskTicket record.
-- CONSTRAINT RequiresMandatory CHECK (ItemCode
-- IN (SELECT ItemCode FROM TaskTicket))
CONSTRAINT ValueAcceptanceDate CHECK (DateAccepted <= CURRENT_DATE),
CONSTRAINT DateOrderCheck CHECK (DateReturned > DateAccepted),
CONSTRAINT ValidInsuranceValue CHECK (InsuranceValue <= 1000000.00)
);
CREATE TABLE Expert(
Name NameString PRIMARY KEY,
Address AddressString NOT NULL,
PublicityText PublicityString,
Email EmailString NOT NULL,
UseInExternalCatalogue YN NOT NULL,
DateApprovedUse DATE NOT NULL,
-- relationship HasExpertiseIn mandatory participation
-- WARNING - the HasExpertiseIn mandatory participation
-- constraint has not been implemented.
-- This omission permits the entry of a row that
-- does not match a related HasExpertiseIn record.
-- CONSTRAINT HasExpertiseInMandatory CHECK (Name
-- IN (SELECT ExpertName FROM HasExpertiseIn))
CONSTRAINT DateApprovedUseValid CHECK (DateApprovedUse <= CURRENT_DATE)
);
CREATE TABLE HasExpertiseIn(
ExpertName NameString,
SpecialismName SpecialismString,
PRIMARY KEY(ExpertName,SpecialismName),
ChargeRate MonetaryValues NOT NULL,
QualificationsHeld QualificationsString,
CONSTRAINT ExpertHasExpertiseIn FOREIGN KEY (ExpertName) REFERENCES Expert,
CONSTRAINT HasExpertiseInSpecialism FOREIGN KEY (SpecialismName) REFERENCES
Specialism
);
CREATE TABLE TaskTicket(
TaskNumber TaskNumbers PRIMARY KEY,
Description DescriptionString NOT NULL,
SpecialismNeeded SpecialismString NOT NULL,
DateCreated DATE NOT NULL,
DateCompleted DATE,
CostOfParts MonetaryValues,
CostOflabour MonetaryValues,
ItemCode ItemCodes NOT NULL,
Name NameString,
CONSTRAINT Needs FOREIGN KEY (SpecialismNeeded) REFERENCES Specialism,
CONSTRAINT Requires FOREIGN KEY (ItemCode) REFERENCES RestorationItem,
CONSTRAINT WorkedOnBy FOREIGN KEY (Name) REFERENCES Expert,
CONSTRAINT DateCreatedValidity CHECK ( DateCreated <= CURRENT_DATE ),
CONSTRAINT DateSequenceValidity CHECK ( DateCompleted >= DateCreated )
);
/* TABLES CREATED */
/* now to populate the tables with data */
INSERT INTO Specialism VALUES ('Clockwork Toys');
INSERT INTO Specialism VALUES ('Clocks');
INSERT INTO Specialism VALUES ('Lighting');
INSERT INTO Specialism VALUES ('Electrical Items');
INSERT INTO Specialism VALUES ('Taxidermy');
INSERT INTO Specialism VALUES ('Tractors');
INSERT INTO Specialism VALUES ('Painting - small scale');
INSERT INTO Specialism VALUES ('Painting - large scale');
INSERT INTO Specialism VALUES ('Stationary Engines, pre-1940');
INSERT INTO Specialism VALUES ('Model Trains - all scales');
INSERT INTO Specialism VALUES ('Lawnmowers pre-1960');
INSERT INTO Specialism VALUES ('Model Steamboats');
INSERT INTO Specialism VALUES ('Welding');
INSERT INTO Specialism VALUES ('Metal Fabrication');
INSERT INTO Specialism VALUES ('Fabric restoration');
INSERT INTO Specialism VALUES ('Woodworking');
INSERT INTO Expert VALUES('Bob','Sunflower Valley','Fixing it since
1999.','bob@theyard','Y','2022-02-01');
INSERT INTO Expert VALUES('Wendy','Fixham Harbour',NULL,
'wendy@harbourview','Y','2022-01-04');
INSERT INTO Expert VALUES('Pilchard','Sunflower Valley','All era, all fabrics, no job too
small.','PT6@sunflowermail','N','2022-02-13');
INSERT INTO Expert VALUES('Leo','Campus Lane','Trains a speciality, also clocks and clockwork
toys.','LeoR12@TheCampus','Y','2022-01-19');
INSERT INTO Expert VALUES('Spud','Pickles Field','All things
steam.','strawman@valley','Y','2022-05-17');
INSERT INTO Expert VALUES('Anish','Ancient Hollow','Restoration paintwork, toys and small
engines a speciality.','digdig@oldground','N','2022-05-11');
INSERT INTO Expert VALUES('Benjamin','The Post Office','Fabrication and welding - no job too
big.','postie1@sortingyard','Y','2022-04-10');
INSERT INTO Expert VALUES('JJ','Spring City','Small scale traction and stationary engines, repair
and refurbishment, call for a quote.','rocket23@SpringCityRockets','Y','2022-05-13');
INSERT INTO Expert VALUES('Angelo','Bobsville Pizzeria','Lighting them up since
1999.','Angelo@bakersfield','N','2022-03-02');
INSERT INTO Expert VALUES('Saffron','Pickles Sunflower Factory','Farm machinery
repairs.','Saff@Pickles','Y','2022-03-10');
INSERT INTO HasExpertiseIn VALUES ('Bob','Welding',23.00,'City&Guilds, Level 3
welding,2021');
INSERT INTO HasExpertiseIn VALUES ('Wendy','Fabric restoration',10.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Pilchard','Fabric restoration',14.00,'Advanced UFT,
2019');
INSERT INTO HasExpertiseIn VALUES ('Pilchard','Taxidermy',25.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Leo','Model Trains - all scales',35.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Leo','Clocks',18.00,'BHI Technician Grade, 2019');
INSERT INTO HasExpertiseIn VALUES ('Leo', 'Clockwork Toys',15.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Spud', 'Model Steamboats',15.50,NULL);
INSERT INTO HasExpertiseIn VALUES ('Spud', 'Stationary Engines, pre-1940',23.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Spud','Metal Fabrication',20.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Spud', 'Tractors',18.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Anish', 'Painting - small scale',16.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Anish', 'Painting - large scale',23.00,'Vehicle body and
paint - level 2 apprenticeship');
INSERT INTO HasExpertiseIn VALUES ('Anish', 'Clockwork Toys',17.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Benjamin','Metal Fabrication',19.00,'Fundamentals of
Metal Fabrication Certificate, 2010');
INSERT INTO HasExpertiseIn VALUES ('Benjamin', 'Welding',22.00,'3G MIG Welding, 2020');
INSERT INTO HasExpertiseIn VALUES ('Benjamin', 'Woodworking',18.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('JJ','Stationary Engines, pre-1940',26.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('JJ','Metal Fabrication',18.00, 'Advanced of Metal
Fabrication Certificate, 2011');
INSERT INTO HasExpertiseIn VALUES ('Angelo','Lighting',19.00,'LIA Certificate - Advanced');
INSERT INTO HasExpertiseIn VALUES ('Angelo','Electrical Items',19.00,'Part P 2393-10');
INSERT INTO HasExpertiseIn VALUES ('Saffron','Tractors',22.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Saffron', 'Metal Fabrication',17.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Saffron','Welding',21.90,'MIG/MAG, TIG and MMA,
ASME IX, TWI, 2020');
INSERT INTO HasExpertiseIn VALUES ('Saffron','Stationary Engines, pre-1940',26.00,NULL);
INSERT INTO RestorationItem VALUES(291,'Ratchet Seed spreader','Straighten ratchet, replace
handle',80.00,15.00,'2022-05-01','2022-05-20',55.00);
INSERT INTO RestorationItem VALUES(101,'Dentist drill, 1940','Improve look', 100.00,
60.00,'2022-05-01','2022-05-22',66.00);
INSERT INTO RestorationItem VALUES(524,'Sir Nigel Gresley, BR Blue, Hattons Original','Align
bogies',900.00,25.00,'2022-04-20','2022-04-30',25.00 );
INSERT INTO RestorationItem VALUES(118,'Chandelier, 200 drop, 6ft diameter, plain','repair and
replace missing elements',870.00,80.00,'2022-04-01',NULL,NULL );
INSERT INTO RestorationItem VALUES(293,'Lister D Type single cylinder petrol engine built Sept
1946','Ensure running and fit to wheeled trailer',400.00,690.00,'2022-05-02','2022-05-18',660.00 );
INSERT INTO RestorationItem VALUES(249,'1928 Ruston Hornby and bamford cornmill','Redress
flywheel, repaint',1500.00,400.00,'2022-03-25','2022-04-15',280.00 );
INSERT INTO RestorationItem VALUES(483,'BAMFORD OPEN CRANK, 1933','try to get
running',300.00, 600.00,'2022-02-02','2022-3-10',630.00);
INSERT INTO RestorationItem VALUES(884,'TIN PLATE WIND UP SPEEDBOAT SCHYLLING
COLLECTOR SERIES','lossen tight spring, make new key',NULL,60.00,'2022-02-17' ,'2022-03-
10',80.00);
INSERT INTO RestorationItem VALUES(937,'Schuco Clockwork Pecking Bird','re-
feather',NULL,30.50,'2022-04-28',NULL,NULL );
INSERT INTO RestorationItem VALUES(867,'Wind-Up Walking Turkey, Blomer & Scholer, US
Zone Germany, 50s.','repaint and reattach foot',100.00,60.00,'2022-03-15','2022-04-05',80.00 );
INSERT INTO RestorationItem VALUES(239,'Foster 4" scale Traction Engine','Make boiler good
for steam',20000.00,1550.00,'2022-04-21',NULL,NULL );
INSERT INTO RestorationItem VALUES(845,'Steam Chair-o-plane, 1910 by Walkers of
Tewkesbury','refit chairs, re-upholster in vintage fabrics',400000.00,5000.00,'2022-01-05','2022-
02-15',2050.00);
INSERT INTO RestorationItem VALUES(224,'Lotus Elan Fuel Gauge, BF2201','re-chrome',NULL,
60.00,'2022-02-27','2022-03-15',100.00 );
INSERT INTO RestorationItem VALUES(163,'Asco Counter Scales, sweet shop','re-balance',
NULL, 25.00,'2022-03-20','2022-04-04',30.00 );
INSERT INTO RestorationItem VALUES(246,'Victorian Brass Postal Scales with Mahogany
Base','replace missing crossrod',100.00,30.00,'2022-03-23','2022-04-14',80.00 );
INSERT INTO RestorationItem VALUES(934,'Ransomes Mg2 Crawler Tractor','retread and clear
oil residue',500.00, 1500.00,'2022-01-02','2022-01-31',1800.00 );
INSERT INTO RestorationItem VALUES(468,'Oxford Allen Scythe, Villiers 4 stroke engine grass
mower cutter brush finger bar','Address finger bar alignment',100.00,30.00,'2022-03-19','2022-03-
29',30.00 );
INSERT INTO RestorationItem VALUES(835,'Plough and ridger','replace plough blade, repaint in
original colours',400.00,350.00,'2022-03-24','2022-04-25',350.00);
INSERT INTO RestorationItem VALUES(348,'Corn mill grinder, 16inch spindle','re-box corn
holder',250.00,100.00,'2022-01-20','2022-02-15',200.00 );
INSERT INTO RestorationItem VALUES(783,'Vintage Antique poss Victorian Rotary Knife Cleaner
Sharpener - premier', 'trim sharpening wheel, re-varnish',200.00,100.00,'2022-03-15',NULL,NULL
);
INSERT INTO RestorationItem VALUES(359,'63inch Gents Railway Station Factory Clock','fit new
hands',5000.00,250.00,'2022-03-12','2022-03-30',110.00 );
INSERT INTO TaskTicket VALUES(100, 'Straighten ratchet','Metal Fabrication','2022-05-02',
'2022-05-06',0.00,28.00,291,'JJ');
INSERT INTO TaskTicket VALUES(101, 'Replace handle','Woodworking','2022-05-02', '2022-05-
09',5.00,22.00,291,'Benjamin');
INSERT INTO TaskTicket VALUES(102, 'Check and refurbish electricals','Electrical
Items','2022-05-02', '2022-05-04',12.00,16.00,101,'Angelo');
INSERT INTO TaskTicket VALUES(103, 'Restore paintwork','Painting - small scale','2022-05-06',
'2022-05-09',18.00,20.00,101,'Anish');
INSERT INTO TaskTicket VALUES(104, 'Align bogies','Model Trains - all
scales','2022-04-21','2022-04-29',0.00,20.00,524,'Leo');
INSERT INTO TaskTicket VALUES(105, 'Repair and replace missing
elements','Lighting','2022-04-03',NULL,NULL,NULL,118,'Angelo');
INSERT INTO TaskTicket VALUES(106, 'Ensure running','Stationary Engines, pre-
1940','2022-05-02', '2022-05-06' ,80.00,140.00,293,'Saffron');
INSERT INTO TaskTicket VALUES(107, 'Construct chassis','Metal
Fabrication','2022-05-02','2022-05-05',110.00,200.00,293,'Spud');
INSERT INTO TaskTicket VALUES(108, 'Construct trolley on
chassis','Woodworking','2022-05-10','2022-05-18',50.00,83.00,293,'Benjamin');
INSERT INTO TaskTicket VALUES(109, 'Redress fly-wheel','Stationary Engines, pre-
1940','2022-03-26','2022-03-29',10.00,23.00,249,'Saffron');
INSERT INTO TaskTicket VALUES(110, 'Repaint','Painting - large scale','2022-03-30','2022-04-
05',105.00,88.00,249,'Anish');
INSERT INTO TaskTicket VALUES(111, 'Overhaul to working state','Stationary Engines, pre-
1940','2022-02-04','2022-02-27',377.00,238.00,483,'Spud');
INSERT INTO TaskTicket VALUES(112, 'Loosen tight spring','Clockwork Toys','2022-02-18','2022-
02-21', 0.00, 40.00,884,'Leo');
INSERT INTO TaskTicket VALUES(113, 'Make new key','Clockwork Toys','2022-02-18','2022-02-
28',5.00,30.00,884,'Leo');
INSERT INTO TaskTicket VALUES(114, 'Re-feather','Taxidermy','2022-04-28',NULL,
NULL,NULL,937,'Pilchard');
INSERT INTO TaskTicket VALUES(115, 'Re-attach foot','Clockwork Toys','2022-03-20','2022-03-
22', 5.00, 20.00,867,'Anish');
INSERT INTO TaskTicket VALUES(116, 'Repaint','Painting - small scale','2022-03-23','2022-03-
29',25.00,25.00,867,'Anish');
INSERT INTO TaskTicket VALUES(117, 'Construct replacement for damaged boiler plates','Metal
Fabrication','2022-04-22',NULL,NULL,NULL,239,'Benjamin');
INSERT INTO TaskTicket VALUES(118, 'Weld new boiler
plates','Welding','2022-04-28',NULL,NULL,NULL,239,'Benjamin');
INSERT INTO TaskTicket VALUES(119, 'Paint boiler','Painting - large
scale','2022-04-30',NULL,NULL,NULL,239,'Anish');
INSERT INTO TaskTicket VALUES(120, 'Replace missing
chairs','Woodworking','2022-01-05','2022-01-13', 250.00,240.00 ,845,'Benjamin');
INSERT INTO TaskTicket VALUES(121, 'Re-upholster all chairs in vintage fabrics','Fabric
restoration','2022-01-15','2022-01-30', 400.00,340.00,845,'Wendy');
INSERT INTO TaskTicket VALUES(122, 'Attach chairs replacing chains as required','Metal
Fabrication','2022-01-31','2022-02-10', 180.00,100.00,845,'Spud');
INSERT INTO TaskTicket VALUES(123, 'Rechrome','Painting - small scale','2022-02-28','2022-03-
12', 40.00,40.00,224,'Anish');
INSERT INTO TaskTicket VALUES(124, 'Rebalance scale','Clockwork Toys','2022-03-22','2022-
03-29', 3.00, 20.00,163,'Anish');
INSERT INTO TaskTicket VALUES(125, 'Replace missing cross-rod','Metal
Fabrication','2022-03-26','2022-03-30', 30.00, 35.00,246,'Spud');
INSERT INTO TaskTicket VALUES(126, 'Retread','Tractors','2022-01-03','2022-01-
18',340.00,120.00 ,934,'Saffron');
INSERT INTO TaskTicket VALUES(127, 'Refurbish engine','Tractors','2022-01-08','2022-01-
26',430.00, 550.00,934,'Saffron');
INSERT INTO TaskTicket VALUES(128, 'Align finger bars','Metal Fabrication','2022-03-19','2022-
03-21', 0.00, 23.00,468,'JJ');
INSERT INTO TaskTicket VALUES(129, 'Replace plough blade','Metal
Fabrication','2022-03-25','2022-03-28',70.00, 35.00,835,'Saffron');
INSERT INTO TaskTicket VALUES(130, 'Repaint with matching original colours','Painting - large
scale','2022-03-29','2022-04-15', 105.00, 95.00,835,'Anish');
INSERT INTO TaskTicket VALUES(131, 'Replace corn holder using
Oak','Woodworking','2022-01-20','2022-01-29', 80.00, 100.00,348,'Benjamin');
INSERT INTO TaskTicket VALUES(132, 'Trim sharpening wheel','Metal
Fabrication','2022-03-16',NULL, NULL,NULL,783,'Spud');
INSERT INTO TaskTicket VALUES(133, 'Re-varnish','Painting - small scale','2022-03-25',NULL,
NULL,NULL,783,'Anish' );
INSERT INTO TaskTicket VALUES(134, 'Fit new hands','Metal Fabrication','2022-03-16','2022-03-
22',30.00, 40.00,359,'JJ' );
/* Data input ends */
/* Use for TM254 2021J, TMA02, Question 6 Copyright 2021 The Open University */
/* Note - all dates are in 'YYYY-MM-DD' format */
/* This overrides the date format set by the local PC locale variable. */
GRANT USAGE ON SCHEMA public TO PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;
/* Evaluate/Run this file in the default database, postgres, and as the*/
/* default user, postgres. */
/* If you re-run the file you will reset any changes you have made to */
/* the database content back to the original content. */
/* The DROP IF EXISTS ensures that when you re-run the script file it */
/* replaces the content of the database, on first run the tables and */
/* domains don't exist so are not dropped and you recieve a warning */
/* message. */
DROP VIEW IF EXISTS Catalogue CASCADE;
DROP TABLE IF EXISTS TaskTicket CASCADE;
DROP TABLE IF EXISTS HasExpertiseIn CASCADE;
DROP TABLE IF EXISTS RestorationItem CASCADE;
DROP TABLE IF EXISTS Expert CASCADE;
DROP TABLE IF EXISTS Specialism CASCADE;
DROP DOMAIN IF EXISTS ItemCodes;
DROP DOMAIN IF EXISTS DescriptionString;
DROP DOMAIN IF EXISTS TaskNumbers;
DROP DOMAIN IF EXISTS NameString;
DROP DOMAIN IF EXISTS AddressString;
DROP DOMAIN IF EXISTS PublicityString;
DROP DOMAIN IF EXISTS EmailString;
DROP DOMAIN IF EXISTS YN;
DROP DOMAIN IF EXISTS SpecialismString;
DROP DOMAIN IF EXISTS QualificationsString;
DROP DOMAIN IF EXISTS MonetaryValues;
/* Now creating the domains */
CREATE DOMAIN ItemCodes AS INTEGER CHECK(VALUE > 0);
CREATE DOMAIN DescriptionString AS VARCHAR(120);
CREATE DOMAIN TaskNumbers AS INTEGER CHECK(VALUE > 0);
CREATE DOMAIN NameString AS VARCHAR(120);
CREATE DOMAIN AddressString AS VARCHAR(400);
CREATE DOMAIN PublicityString AS VARCHAR(120);
CREATE DOMAIN EmailString AS VARCHAR(100) CHECK (VALUE LIKE ('%@%'));
CREATE DOMAIN YN AS CHAR(1) CHECK(VALUE IN ('Y','N') );
CREATE DOMAIN SpecialismString AS VARCHAR(120);
CREATE DOMAIN QualificationsString AS VARCHAR(300);
CREATE DOMAIN MonetaryValues AS NUMERIC(9,2) CHECK (VALUE >= 0.00);
/* DOMAINS CREATED */
/* now creating tables */
CREATE TABLE Specialism(
Name SpecialismString PRIMARY KEY
);
CREATE TABLE RestorationItem(
ItemCode ItemCodes PRIMARY KEY,
ItemDescription DescriptionString NOT NULL,
WorkDescription DescriptionString NOT NULL,
InsuranceValue MonetaryValues,
CostEstimate MonetaryValues NOT NULL,
DateAccepted DATE NOT NULL,
DateReturned DATE,
PriceCharged MonetaryValues,
-- relationship Requires mandatory participation
-- WARNING - the requires mandatory participation
-- constraint has not been implemented.
-- This omission permits the entry of a row that
-- does not match a related TaskTicket record.
-- CONSTRAINT RequiresMandatory CHECK (ItemCode
-- IN (SELECT ItemCode FROM TaskTicket))
CONSTRAINT ValueAcceptanceDate CHECK (DateAccepted <= CURRENT_DATE),
CONSTRAINT DateOrderCheck CHECK (DateReturned > DateAccepted),
CONSTRAINT ValidInsuranceValue CHECK (InsuranceValue <= 1000000.00)
);
CREATE TABLE Expert(
Name NameString PRIMARY KEY,
Address AddressString NOT NULL,
PublicityText PublicityString,
Email EmailString NOT NULL,
UseInExternalCatalogue YN NOT NULL,
DateApprovedUse DATE NOT NULL,
-- relationship HasExpertiseIn mandatory participation
-- WARNING - the HasExpertiseIn mandatory participation
-- constraint has not been implemented.
-- This omission permits the entry of a row that
-- does not match a related HasExpertiseIn record.
-- CONSTRAINT HasExpertiseInMandatory CHECK (Name
-- IN (SELECT ExpertName FROM HasExpertiseIn))
CONSTRAINT DateApprovedUseValid CHECK (DateApprovedUse <= CURRENT_DATE)
);
CREATE TABLE HasExpertiseIn(
ExpertName NameString,
SpecialismName SpecialismString,
PRIMARY KEY(ExpertName,SpecialismName),
ChargeRate MonetaryValues NOT NULL,
QualificationsHeld QualificationsString,
CONSTRAINT ExpertHasExpertiseIn FOREIGN KEY (ExpertName) REFERENCES Expert,
CONSTRAINT HasExpertiseInSpecialism FOREIGN KEY (SpecialismName) REFERENCES
Specialism
);
CREATE TABLE TaskTicket(
TaskNumber TaskNumbers PRIMARY KEY,
Description DescriptionString NOT NULL,
SpecialismNeeded SpecialismString NOT NULL,
DateCreated DATE NOT NULL,
DateCompleted DATE,
CostOfParts MonetaryValues,
CostOflabour MonetaryValues,
ItemCode ItemCodes NOT NULL,
Name NameString,
CONSTRAINT Needs FOREIGN KEY (SpecialismNeeded) REFERENCES Specialism,
CONSTRAINT Requires FOREIGN KEY (ItemCode) REFERENCES RestorationItem,
CONSTRAINT WorkedOnBy FOREIGN KEY (Name) REFERENCES Expert,
CONSTRAINT DateCreatedValidity CHECK ( DateCreated <= CURRENT_DATE ),
CONSTRAINT DateSequenceValidity CHECK ( DateCompleted >= DateCreated )
);
/* TABLES CREATED */
/* now to populate the tables with data */
INSERT INTO Specialism VALUES ('Clockwork Toys');
INSERT INTO Specialism VALUES ('Clocks');
INSERT INTO Specialism VALUES ('Lighting');
INSERT INTO Specialism VALUES ('Electrical Items');
INSERT INTO Specialism VALUES ('Taxidermy');
INSERT INTO Specialism VALUES ('Tractors');
INSERT INTO Specialism VALUES ('Painting - small scale');
INSERT INTO Specialism VALUES ('Painting - large scale');
INSERT INTO Specialism VALUES ('Stationary Engines, pre-1940');
INSERT INTO Specialism VALUES ('Model Trains - all scales');
INSERT INTO Specialism VALUES ('Lawnmowers pre-1960');
INSERT INTO Specialism VALUES ('Model Steamboats');
INSERT INTO Specialism VALUES ('Welding');
INSERT INTO Specialism VALUES ('Metal Fabrication');
INSERT INTO Specialism VALUES ('Fabric restoration');
INSERT INTO Specialism VALUES ('Woodworking');
INSERT INTO Expert VALUES('Bob','Sunflower Valley','Fixing it since
1999.','bob@theyard','Y','2022-02-01');
INSERT INTO Expert VALUES('Wendy','Fixham Harbour',NULL,
'wendy@harbourview','Y','2022-01-04');
INSERT INTO Expert VALUES('Pilchard','Sunflower Valley','All era, all fabrics, no job too
small.','PT6@sunflowermail','N','2022-02-13');
INSERT INTO Expert VALUES('Leo','Campus Lane','Trains a speciality, also clocks and clockwork
toys.','LeoR12@TheCampus','Y','2022-01-19');
INSERT INTO Expert VALUES('Spud','Pickles Field','All things
steam.','strawman@valley','Y','2022-05-17');
INSERT INTO Expert VALUES('Anish','Ancient Hollow','Restoration paintwork, toys and small
engines a speciality.','digdig@oldground','N','2022-05-11');
INSERT INTO Expert VALUES('Benjamin','The Post Office','Fabrication and welding - no job too
big.','postie1@sortingyard','Y','2022-04-10');
INSERT INTO Expert VALUES('JJ','Spring City','Small scale traction and stationary engines, repair
and refurbishment, call for a quote.','rocket23@SpringCityRockets','Y','2022-05-13');
INSERT INTO Expert VALUES('Angelo','Bobsville Pizzeria','Lighting them up since
1999.','Angelo@bakersfield','N','2022-03-02');
INSERT INTO Expert VALUES('Saffron','Pickles Sunflower Factory','Farm machinery
repairs.','Saff@Pickles','Y','2022-03-10');
INSERT INTO HasExpertiseIn VALUES ('Bob','Welding',23.00,'City&Guilds, Level 3
welding,2021');
INSERT INTO HasExpertiseIn VALUES ('Wendy','Fabric restoration',10.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Pilchard','Fabric restoration',14.00,'Advanced UFT,
2019');
INSERT INTO HasExpertiseIn VALUES ('Pilchard','Taxidermy',25.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Leo','Model Trains - all scales',35.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Leo','Clocks',18.00,'BHI Technician Grade, 2019');
INSERT INTO HasExpertiseIn VALUES ('Leo', 'Clockwork Toys',15.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Spud', 'Model Steamboats',15.50,NULL);
INSERT INTO HasExpertiseIn VALUES ('Spud', 'Stationary Engines, pre-1940',23.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Spud','Metal Fabrication',20.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Spud', 'Tractors',18.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Anish', 'Painting - small scale',16.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Anish', 'Painting - large scale',23.00,'Vehicle body and
paint - level 2 apprenticeship');
INSERT INTO HasExpertiseIn VALUES ('Anish', 'Clockwork Toys',17.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Benjamin','Metal Fabrication',19.00,'Fundamentals of
Metal Fabrication Certificate, 2010');
INSERT INTO HasExpertiseIn VALUES ('Benjamin', 'Welding',22.00,'3G MIG Welding, 2020');
INSERT INTO HasExpertiseIn VALUES ('Benjamin', 'Woodworking',18.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('JJ','Stationary Engines, pre-1940',26.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('JJ','Metal Fabrication',18.00, 'Advanced of Metal
Fabrication Certificate, 2011');
INSERT INTO HasExpertiseIn VALUES ('Angelo','Lighting',19.00,'LIA Certificate - Advanced');
INSERT INTO HasExpertiseIn VALUES ('Angelo','Electrical Items',19.00,'Part P 2393-10');
INSERT INTO HasExpertiseIn VALUES ('Saffron','Tractors',22.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Saffron', 'Metal Fabrication',17.00,NULL);
INSERT INTO HasExpertiseIn VALUES ('Saffron','Welding',21.90,'MIG/MAG, TIG and MMA,
ASME IX, TWI, 2020');
INSERT INTO HasExpertiseIn VALUES ('Saffron','Stationary Engines, pre-1940',26.00,NULL);
INSERT INTO RestorationItem VALUES(291,'Ratchet Seed spreader','Straighten ratchet, replace
handle',80.00,15.00,'2022-05-01','2022-05-20',55.00);
INSERT INTO RestorationItem VALUES(101,'Dentist drill, 1940','Improve look', 100.00,
60.00,'2022-05-01','2022-05-22',66.00);
INSERT INTO RestorationItem VALUES(524,'Sir Nigel Gresley, BR Blue, Hattons Original','Align
bogies',900.00,25.00,'2022-04-20','2022-04-30',25.00 );
INSERT INTO RestorationItem VALUES(118,'Chandelier, 200 drop, 6ft diameter, plain','repair and
replace missing elements',870.00,80.00,'2022-04-01',NULL,NULL );
INSERT INTO RestorationItem VALUES(293,'Lister D Type single cylinder petrol engine built Sept
1946','Ensure running and fit to wheeled trailer',400.00,690.00,'2022-05-02','2022-05-18',660.00 );
INSERT INTO RestorationItem VALUES(249,'1928 Ruston Hornby and bamford cornmill','Redress
flywheel, repaint',1500.00,400.00,'2022-03-25','2022-04-15',280.00 );
INSERT INTO RestorationItem VALUES(483,'BAMFORD OPEN CRANK, 1933','try to get
running',300.00, 600.00,'2022-02-02','2022-3-10',630.00);
INSERT INTO RestorationItem VALUES(884,'TIN PLATE WIND UP SPEEDBOAT SCHYLLING
COLLECTOR SERIES','lossen tight spring, make new key',NULL,60.00,'2022-02-17' ,'2022-03-
10',80.00);
INSERT INTO RestorationItem VALUES(937,'Schuco Clockwork Pecking Bird','re-
feather',NULL,30.50,'2022-04-28',NULL,NULL );
INSERT INTO RestorationItem VALUES(867,'Wind-Up Walking Turkey, Blomer & Scholer, US
Zone Germany, 50s.','repaint and reattach foot',100.00,60.00,'2022-03-15','2022-04-05',80.00 );
INSERT INTO RestorationItem VALUES(239,'Foster 4" scale Traction Engine','Make boiler good
for steam',20000.00,1550.00,'2022-04-21',NULL,NULL );
INSERT INTO RestorationItem VALUES(845,'Steam Chair-o-plane, 1910 by Walkers of
Tewkesbury','refit chairs, re-upholster in vintage fabrics',400000.00,5000.00,'2022-01-05','2022-
02-15',2050.00);
INSERT INTO RestorationItem VALUES(224,'Lotus Elan Fuel Gauge, BF2201','re-chrome',NULL,
60.00,'2022-02-27','2022-03-15',100.00 );
INSERT INTO RestorationItem VALUES(163,'Asco Counter Scales, sweet shop','re-balance',
NULL, 25.00,'2022-03-20','2022-04-04',30.00 );
INSERT INTO RestorationItem VALUES(246,'Victorian Brass Postal Scales with Mahogany
Base','replace missing crossrod',100.00,30.00,'2022-03-23','2022-04-14',80.00 );
INSERT INTO RestorationItem VALUES(934,'Ransomes Mg2 Crawler Tractor','retread and clear
oil residue',500.00, 1500.00,'2022-01-02','2022-01-31',1800.00 );
INSERT INTO RestorationItem VALUES(468,'Oxford Allen Scythe, Villiers 4 stroke engine grass
mower cutter brush finger bar','Address finger bar alignment',100.00,30.00,'2022-03-19','2022-03-
29',30.00 );
INSERT INTO RestorationItem VALUES(835,'Plough and ridger','replace plough blade, repaint in
original colours',400.00,350.00,'2022-03-24','2022-04-25',350.00);
INSERT INTO RestorationItem VALUES(348,'Corn mill grinder, 16inch spindle','re-box corn
holder',250.00,100.00,'2022-01-20','2022-02-15',200.00 );
INSERT INTO RestorationItem VALUES(783,'Vintage Antique poss Victorian Rotary Knife Cleaner
Sharpener - premier', 'trim sharpening wheel, re-varnish',200.00,100.00,'2022-03-15',NULL,NULL
);
INSERT INTO RestorationItem VALUES(359,'63inch Gents Railway Station Factory Clock','fit new
hands',5000.00,250.00,'2022-03-12','2022-03-30',110.00 );
INSERT INTO TaskTicket VALUES(100, 'Straighten ratchet','Metal Fabrication','2022-05-02',
'2022-05-06',0.00,28.00,291,'JJ');
INSERT INTO TaskTicket VALUES(101, 'Replace handle','Woodworking','2022-05-02', '2022-05-
09',5.00,22.00,291,'Benjamin');
INSERT INTO TaskTicket VALUES(102, 'Check and refurbish electricals','Electrical
Items','2022-05-02', '2022-05-04',12.00,16.00,101,'Angelo');
INSERT INTO TaskTicket VALUES(103, 'Restore paintwork','Painting - small scale','2022-05-06',
'2022-05-09',18.00,20.00,101,'Anish');
INSERT INTO TaskTicket VALUES(104, 'Align bogies','Model Trains - all
scales','2022-04-21','2022-04-29',0.00,20.00,524,'Leo');
INSERT INTO TaskTicket VALUES(105, 'Repair and replace missing
elements','Lighting','2022-04-03',NULL,NULL,NULL,118,'Angelo');
INSERT INTO TaskTicket VALUES(106, 'Ensure running','Stationary Engines, pre-
1940','2022-05-02', '2022-05-06' ,80.00,140.00,293,'Saffron');
INSERT INTO TaskTicket VALUES(107, 'Construct chassis','Metal
Fabrication','2022-05-02','2022-05-05',110.00,200.00,293,'Spud');
INSERT INTO TaskTicket VALUES(108, 'Construct trolley on
chassis','Woodworking','2022-05-10','2022-05-18',50.00,83.00,293,'Benjamin');
INSERT INTO TaskTicket VALUES(109, 'Redress fly-wheel','Stationary Engines, pre-
1940','2022-03-26','2022-03-29',10.00,23.00,249,'Saffron');
INSERT INTO TaskTicket VALUES(110, 'Repaint','Painting - large scale','2022-03-30','2022-04-
05',105.00,88.00,249,'Anish');
INSERT INTO TaskTicket VALUES(111, 'Overhaul to working state','Stationary Engines, pre-
1940','2022-02-04','2022-02-27',377.00,238.00,483,'Spud');
INSERT INTO TaskTicket VALUES(112, 'Loosen tight spring','Clockwork Toys','2022-02-18','2022-
02-21', 0.00, 40.00,884,'Leo');
INSERT INTO TaskTicket VALUES(113, 'Make new key','Clockwork Toys','2022-02-18','2022-02-
28',5.00,30.00,884,'Leo');
INSERT INTO TaskTicket VALUES(114, 'Re-feather','Taxidermy','2022-04-28',NULL,
NULL,NULL,937,'Pilchard');
INSERT INTO TaskTicket VALUES(115, 'Re-attach foot','Clockwork Toys','2022-03-20','2022-03-
22', 5.00, 20.00,867,'Anish');
INSERT INTO TaskTicket VALUES(116, 'Repaint','Painting - small scale','2022-03-23','2022-03-
29',25.00,25.00,867,'Anish');
INSERT INTO TaskTicket VALUES(117, 'Construct replacement for damaged boiler plates','Metal
Fabrication','2022-04-22',NULL,NULL,NULL,239,'Benjamin');
INSERT INTO TaskTicket VALUES(118, 'Weld new boiler
plates','Welding','2022-04-28',NULL,NULL,NULL,239,'Benjamin');
INSERT INTO TaskTicket VALUES(119, 'Paint boiler','Painting - large
scale','2022-04-30',NULL,NULL,NULL,239,'Anish');
INSERT INTO TaskTicket VALUES(120, 'Replace missing
chairs','Woodworking','2022-01-05','2022-01-13', 250.00,240.00 ,845,'Benjamin');
INSERT INTO TaskTicket VALUES(121, 'Re-upholster all chairs in vintage fabrics','Fabric
restoration','2022-01-15','2022-01-30', 400.00,340.00,845,'Wendy');
INSERT INTO TaskTicket VALUES(122, 'Attach chairs replacing chains as required','Metal
Fabrication','2022-01-31','2022-02-10', 180.00,100.00,845,'Spud');
INSERT INTO TaskTicket VALUES(123, 'Rechrome','Painting - small scale','2022-02-28','2022-03-
12', 40.00,40.00,224,'Anish');
INSERT INTO TaskTicket VALUES(124, 'Rebalance scale','Clockwork Toys','2022-03-22','2022-
03-29', 3.00, 20.00,163,'Anish');
INSERT INTO TaskTicket VALUES(125, 'Replace missing cross-rod','Metal
Fabrication','2022-03-26','2022-03-30', 30.00, 35.00,246,'Spud');
INSERT INTO TaskTicket VALUES(126, 'Retread','Tractors','2022-01-03','2022-01-
18',340.00,120.00 ,934,'Saffron');
INSERT INTO TaskTicket VALUES(127, 'Refurbish engine','Tractors','2022-01-08','2022-01-
26',430.00, 550.00,934,'Saffron');
INSERT INTO TaskTicket VALUES(128, 'Align finger bars','Metal Fabrication','2022-03-19','2022-
03-21', 0.00, 23.00,468,'JJ');
INSERT INTO TaskTicket VALUES(129, 'Replace plough blade','Metal
Fabrication','2022-03-25','2022-03-28',70.00, 35.00,835,'Saffron');
INSERT INTO TaskTicket VALUES(130, 'Repaint with matching original colours','Painting - large
scale','2022-03-29','2022-04-15', 105.00, 95.00,835,'Anish');
INSERT INTO TaskTicket VALUES(131, 'Replace corn holder using
Oak','Woodworking','2022-01-20','2022-01-29', 80.00, 100.00,348,'Benjamin');
INSERT INTO TaskTicket VALUES(132, 'Trim sharpening wheel','Metal
Fabrication','2022-03-16',NULL, NULL,NULL,783,'Spud');
INSERT INTO TaskTicket VALUES(133, 'Re-varnish','Painting - small scale','2022-03-25',NULL,
NULL,NULL,783,'Anish' );
INSERT INTO TaskTicket VALUES(134, 'Fit new hands','Metal Fabrication','2022-03-16','2022-03-
22',30.00, 40.00,359,'JJ' );
/* Data input ends */
Resto schema description Resto is a database package that holds the data records for Walton
Restorations. For this scenario we are interested in the data that the resto database handles about
items for restoration, the tasks needed to complete the restoration, the experts who perform the
restoration, and the specialisms needed to complete the tasks. In particular, we are interested in
which restoration item requires which tasks, which task is worked on by which experts, which
tasks need what specialisms and which expert has expertise in which specialism. Each restoration
item must require one or more tasks. Each task must be required by at most one restoration item.
Each task may be worked on by at most one expert (this allows a task to be created where an
expert has not yet been allocated to work on it). Each expert may work on one or more tasks.
Each task must need at most one specialism. Each specialism may be needed on one or more
tasks. Each expert must have expertise in one or more specialisms. Each specialism may be the
expertise of one or more experts. The information held about restoration items is a unique item
code, a description of the item and a description of the work required, along with the insurance
value of the item, an estimate for the cost of the work, and the date the item was accepted by
Walton Restorations. When work is completed and the item returned there will also be a value for
the price charged for the work, and the date It was returned to the client. Walton Restorations do
not accept items with an insurance value of greater than one million pounds.Experts have a name,
address and email held. (Names are assumed to be unique). Walton Resto also holds some
publicity text, if the expert wants to supply some. Walton resto has a record of permission (or not)
being given to include the expert's details in the online catalogue, and the date when the
permission was given. A list of specialisms is held. And each expert is associated with any of
these that they have expertise in. For each specialism held, the expert has a particular charge rate
and may hold qualifications related to that expertise. A task (also known as a task ticket) is
identified in the resto database using a unique task number issued when it is created. Task
information includes a description of the task, and the day the task was created. When a task is
complete, the task-ticket is updated by adding the cost of the parts used, the cost of the expert
labour used, and the date it was completed. If a task is incomplete then these will be NULL. The
domain and datatype descriptions of the attributes in resto are shown in Figure 8. Note this is a
simplified scenario as we aren't including details of the Clients, Manager or Parts Used related to
restoration process. (Note this description is also given in the resto_schema document).Resto
Entity Relationship diagramFigure 7 An entity relationship diagram showing Restorationltem,
TaskTicket, Expert and Specialism entity types and the relationship types Requires, WorkedOnBy,
HasExpertiseln and Needs. (Note this figure is also given in the resto_schema document).Figure 8
A schema and description of the tables defined in the resto.txt file (note this is also given in the
resto_schema document).. Figure 8 This shows a physical schema model consisting of five
relations: Restorationltem, TaskTicket, Expert, Specialism and HasExpertiseln. There is an
unlabelled line between Restorationitem and TaskTicket, TaskTicket and Expert, TaskTicket and
Specialism and Specialism and HasExpertiseln and Expert and HasExpertiseln. There is also a
'note' box labelled Domain definitions.The note box labelled 'Domain definitions' contains domain
descriptions for eleven domains: ItemCodes: INTEGER CHECK (VALUE>0), DescriptionString:
VARCHAR(120), TaskNumbers: INTEGER CHECK (VALUE)>0), NameString: VARCHAR(120),
AddressString: VARCHAR(400), Publicitystring: VARCHAR(120), EmailString: VARCHAR(100)
CHECK (VALUE LIKE %@%'), YN: CHECK (VALUE IN ('Y','N;')), SpecialismString: VARCHAR
(300), QualificationString: VARCHAR(300) and MonetaryValues: NUMERIC (9,2) CHECK
(VALUE>=0.00) The Restorationltem has eight attributes and three constraints. The attributes are
ItemCode: ItemCodes , ItemDescription: Descriptionstring , WorkDescription: DescriptionString ,
InsuranceValue: MonetaryValues, CostEstimate: Montearyvalue , DateAccepted: DATE ,
DateReturned: DATE and PriceCharged: MonetaryValues. The three constraints state: Requires
mandatory: all values of ItemCode must appear in the TaskTicket relation foreign key attribute
(ItemCode) representing Requires. 1: DateAccepted must be today or earlier, 2: DateAccepted
must be before Date Returned and 3 : InsuranceValue must be below 1 Million. The TaskTicket
has nine attributes, three foreign keys and two constraints. The attributes are TaskNumber:
TaskNumbers , Description: DescriptionString , SpecialismNeeded: SpecialismString,
DateCreated: DATE , DateCompleted: DATE, CostOfParts: MonetaryValues, CostOfLabour:
MonetaryValues, ItemCode: ItemCodes and Name: NameString. The foreign keys are:
Name(Requires) ItemCode References Restorationltem , Name(WorkedOnBy) Name References
Expert and Name(Needs) SpecialismNeeded References SpecialismName(Needs)
SpecialismNeeded References Specialism < not null>. The two constraints are: 1 : DateCreated
must be today or earlier and 2: DateCreated must be before DateCompleted. The Expert has six
attributes and two constraints. The attributes are Name: NameString , Address: AddressString ,
PublicityText; PublicityString, Email: EmailString , UselnExternal Catalogue: YN and
DateApprovedUse: DATE . The constraints are HasExpertiseln mandatory: all values of name
must appear in the HasExpertiseln relation foreign key attribute (ExpertName). and 1: Date
ApprovedUse must be today or earlier. The Specialism has one attribute. The attribute is Name:
SpecialismString . The HasExpertiseln has four attributes, two foreign keys and one note. The
attributes are: Expertname: NameString < primary key>, SpecialismName: SpecialismString ,
ChargeRate: MonetaryValues and QualificationsHeld: QualificationsString. The foreign keys are:
Name(HasExpertiseln) ExpertName References Expert and Name(HasExpertiseln)
SpecialismName References Specialism. The Note is: 1 . ChargeRate is per hour. a. Write SQL
statements that answer each of the requests for data in the resto.txt tables: i. Produce a list of the
expert names, rename the output column as experts. (3 marks)ii. Produce a list of the item codes
and date accepted, for any restoration item that has not yet been returned. (4 marks) iii. How
many task tickets have been created where the specialism needed is 'Tractors'? (3 marks) iv. How
many restoration items have been returned? (3 marks) v. List the item code and date accepted for
all restoration items that have been accepted between 2022-03-31 and 2022-05-01, but not yet
returned (3 marks) vi. List the task number, specialism needed and item code for all task tickets
where the description includes mention of 'replace'. (3 marks) vii. For each expert and their
specialisms, list the expert's name, email, the specialism and their charge-rate for that specialism.
Sort the output by specialism and then by charge-rate (descending order in each case). (3
marks)ii. Produce a list of the item codes and date accepted, for any restoration item that has not
yet been returned. (4 marks) iii. How many task tickets have been created where the specialism
needed is 'Tractors'? (3 marks) iv. How many restoration items have been returned? (3 marks) v.
List the item code and date accepted for all restoration items that have been accepted between
2022-03-31 and 2022-05-01, but not yet returned (3 marks) vi. List the task number, specialism
needed and item code for all task tickets where the description includes mention of 'replace'. (3
marks) vii. For each expert and their specialisms, list the expert's name, email, the specialism and
their charge-rate for that specialism. Sort the output by specialism and then by charge-rate
(descending order in each case). (3 marks)viii. For each expert and their specialisms, if they have
given permission for their details to appear in the catalogue, list the expert's name, email, the
specialism and their charge-rate for that specialism. Sort the output by specialism and then by
charge-rate (descending order in each case). (2 marks) ix. For each restoration item that has an
insurance value of over 300.00, and has a task ticket that was worked on by an expert called
'Benjamin', give the item code, item description, and insurance value. The list should be in order of
item code. (4 marks) x. List any expert that has not worked on any tasks. (3 marks) xi. For each
task ticket that has been completed, list the task number, item code and the combined cost of
parts and labour, for that task, under the heading costs. Show the list in order of the item code
values. (4 marks) xii. For each restoration item, list the item code and the number of task tickets
created for that item. (4 marks)xiii. For each restoration item that has been returned, list the item
code and the sum of the total cost of parts and labour for all task tickets related to that item code.
Give the sum of costs column the heading total_cost and display the result in ascending order of
this column. (5 marks) (44 marks) b. What request does the following SQL answer? (Note that a
request should be an English language question or description like the ones in part a), not an
account of how the data is processed to produce the result.) SELECT Name, COUNT
(SpecialismName) FROM Expert JOIN HasExpertiseIn ON Name = ExpertN: WHERE
UseInExternalCatalogue = ' Y ' GROUP BY Name HAVING COUNT (SpecialismName) > 2; (5
marks) c. Describe, using the logical processing model, the evaluation of the following query:
SELECT Name, COUNT(*) FROM TaskTicket WHERE DateCompleted IS NULL GROUP BY
Name HAVING COUNT ()>1;d. Consider the information: The work described by task ticket 117
has been completed by Benjamin on 2022-04-26. Benjamin's labour was 88.00 and they used
110.00 in parts. Add this information to the task ticket table using an SQL UPDATE statement,
then write a query to show that your update was successful. NOTE: after you successfully run this
UPDATE it will change some of the results you achieve with the queries you wrote in part a). If you
have not yet produced the output data for your TMA submission document, you will need to re-run
resto.txt in order to reset the content of the database. ( 3 marks) e. Describe the effect of the LEFT
OUTER JOIN in SQL when used to join the Specialism and HasExpertiseIn tables on the Name =
SpecialismName attribute comparison. SELECT Name, ExpertName FROM Specialism LEFT
OUTER JOIN HasExpertiseIn ON Name = SpecialismName ORDER BY Name; What request
would that LEFT OUTER JOIN satisfy? (5 marks)f. Walton Restorations wants to produce the data
for their online catalogue. You are to create an SQL VIEW with the name 'Catalogue'. The view
should produce rows showing each expert's name, email address, specialism, charge-rate and
qualifications they hold. The view should have columns named Name, ContactEmail, Specialism,
HourlyRate and RelevantQualification. Only data where the expert has given permission to be
included in the catalogue should appear in the data defined by the VIEW. Write a query showing
the data your VIEW defines. Your solution document should contain the CREATE VIEW
statement, the query and the output of the query. (5 marks) HAVE YOU INCLUDED YOUR SQL
AND OUTPUT IN YOUR SOLUTION DOCUMENT? For this question, in your solution document
you MUST include your SQL statements and a copy of the output produced by the evaluation of
each of your statements. If you were unable to produce a working query then a copy of any error
messages should be included in your solution. A text copy-and-paste of the SQL statements and
output should be used. Please do not use screenshots for your SQL statement and output, as they
are difficult to annotate for feedback and marking. If you do not include both SQL statement and
output (or error messages) then your tutor will not mark your answer for that part of the question.

More Related Content

Similar to The resto txt Use for TM254 2021J TMA02 Question 6 .pdf

SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdfSQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdfarrowit1
 
I have the attached copy of the assignment description. And here is .docx
I have the attached copy of the assignment description. And here is .docxI have the attached copy of the assignment description. And here is .docx
I have the attached copy of the assignment description. And here is .docxsamirapdcosden
 
- Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
 - Php myadmin sql dump-- version 4.0.10.7-- httpwww.php - Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
- Php myadmin sql dump-- version 4.0.10.7-- httpwww.phpssuserfa5723
 
Appendix A Tables
Appendix A   TablesAppendix A   Tables
Appendix A TablesLiquidHub
 
Database Implementation Final Document
Database Implementation Final DocumentDatabase Implementation Final Document
Database Implementation Final DocumentConor O'Callaghan
 
I am working on this homework using MYSQL database. Can you help. At.docx
I am working on this homework using MYSQL database. Can you help. At.docxI am working on this homework using MYSQL database. Can you help. At.docx
I am working on this homework using MYSQL database. Can you help. At.docxmaple8qvlisbey
 
CCM Escape Case Study - SkySQL Paris Meetup 17.12.2013
CCM Escape Case Study - SkySQL Paris Meetup 17.12.2013CCM Escape Case Study - SkySQL Paris Meetup 17.12.2013
CCM Escape Case Study - SkySQL Paris Meetup 17.12.2013MariaDB Corporation
 
Scott sql script as per exercise1
Scott sql script as per exercise1Scott sql script as per exercise1
Scott sql script as per exercise1AjayMaheshwari17
 
Starting from the database used in Project 1 (see the slightly cha.docx
Starting from the database used in Project 1 (see the slightly cha.docxStarting from the database used in Project 1 (see the slightly cha.docx
Starting from the database used in Project 1 (see the slightly cha.docxdessiechisomjj4
 
BREWBEANS.sql.txtDROP TABLE BB_Department CASCADE CONSTRAINTS .docx
BREWBEANS.sql.txtDROP TABLE BB_Department CASCADE CONSTRAINTS .docxBREWBEANS.sql.txtDROP TABLE BB_Department CASCADE CONSTRAINTS .docx
BREWBEANS.sql.txtDROP TABLE BB_Department CASCADE CONSTRAINTS .docxhartrobert670
 
Enterprise workflow with Apps Script
Enterprise workflow with Apps ScriptEnterprise workflow with Apps Script
Enterprise workflow with Apps Scriptccherubino
 
Databricks Sql cheatseet for professional exam
Databricks Sql cheatseet for professional examDatabricks Sql cheatseet for professional exam
Databricks Sql cheatseet for professional examRupiniSarguru
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfsooryasalini
 
Relay Modern: architecture and workflow
Relay Modern: architecture and workflowRelay Modern: architecture and workflow
Relay Modern: architecture and workflowAlex Alexeev
 
Sql 99 and_some_techniques
Sql 99 and_some_techniquesSql 99 and_some_techniques
Sql 99 and_some_techniquesAlexey Kiselyov
 

Similar to The resto txt Use for TM254 2021J TMA02 Question 6 .pdf (20)

SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdfSQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
 
I have the attached copy of the assignment description. And here is .docx
I have the attached copy of the assignment description. And here is .docxI have the attached copy of the assignment description. And here is .docx
I have the attached copy of the assignment description. And here is .docx
 
- Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
 - Php myadmin sql dump-- version 4.0.10.7-- httpwww.php - Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
- Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
 
Appendix A Tables
Appendix A   TablesAppendix A   Tables
Appendix A Tables
 
Database Implementation Final Document
Database Implementation Final DocumentDatabase Implementation Final Document
Database Implementation Final Document
 
Actividad 1
Actividad 1Actividad 1
Actividad 1
 
I am working on this homework using MYSQL database. Can you help. At.docx
I am working on this homework using MYSQL database. Can you help. At.docxI am working on this homework using MYSQL database. Can you help. At.docx
I am working on this homework using MYSQL database. Can you help. At.docx
 
Sql commands
Sql commandsSql commands
Sql commands
 
CCM Escape Case Study - SkySQL Paris Meetup 17.12.2013
CCM Escape Case Study - SkySQL Paris Meetup 17.12.2013CCM Escape Case Study - SkySQL Paris Meetup 17.12.2013
CCM Escape Case Study - SkySQL Paris Meetup 17.12.2013
 
Scott sql script as per exercise1
Scott sql script as per exercise1Scott sql script as per exercise1
Scott sql script as per exercise1
 
Starting from the database used in Project 1 (see the slightly cha.docx
Starting from the database used in Project 1 (see the slightly cha.docxStarting from the database used in Project 1 (see the slightly cha.docx
Starting from the database used in Project 1 (see the slightly cha.docx
 
ES6 - Level up your JavaScript Skills
ES6 - Level up your JavaScript SkillsES6 - Level up your JavaScript Skills
ES6 - Level up your JavaScript Skills
 
Presentation.pdf
Presentation.pdfPresentation.pdf
Presentation.pdf
 
BREWBEANS.sql.txtDROP TABLE BB_Department CASCADE CONSTRAINTS .docx
BREWBEANS.sql.txtDROP TABLE BB_Department CASCADE CONSTRAINTS .docxBREWBEANS.sql.txtDROP TABLE BB_Department CASCADE CONSTRAINTS .docx
BREWBEANS.sql.txtDROP TABLE BB_Department CASCADE CONSTRAINTS .docx
 
Enterprise workflow with Apps Script
Enterprise workflow with Apps ScriptEnterprise workflow with Apps Script
Enterprise workflow with Apps Script
 
Databricks Sql cheatseet for professional exam
Databricks Sql cheatseet for professional examDatabricks Sql cheatseet for professional exam
Databricks Sql cheatseet for professional exam
 
Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdf
 
Relay Modern: architecture and workflow
Relay Modern: architecture and workflowRelay Modern: architecture and workflow
Relay Modern: architecture and workflow
 
Sql 99 and_some_techniques
Sql 99 and_some_techniquesSql 99 and_some_techniques
Sql 99 and_some_techniques
 

More from giriraj65

Which of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdfWhich of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdfgiriraj65
 
Wheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdfWheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdfgiriraj65
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfgiriraj65
 
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdfTableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdfgiriraj65
 
Rios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdfRios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdfgiriraj65
 
Question 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdfQuestion 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdfgiriraj65
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfgiriraj65
 
Problem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdfProblem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdfgiriraj65
 
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdfPLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdfgiriraj65
 
Please discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdfPlease discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdfgiriraj65
 
Mill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdfMill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdfgiriraj65
 
For each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdfFor each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdfgiriraj65
 
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1  Geor.pdfExercise I Georgettes and Georges Genotypes Gene 1  Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdfgiriraj65
 
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdfEl 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdfgiriraj65
 
Ests realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdfEsts realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdfgiriraj65
 
Assume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdfAssume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdfgiriraj65
 
a How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdfa How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdfgiriraj65
 
A Bucle remolino y arco B Crestas surcos y colinas .pdf
A  Bucle remolino y arco   B  Crestas surcos y colinas  .pdfA  Bucle remolino y arco   B  Crestas surcos y colinas  .pdf
A Bucle remolino y arco B Crestas surcos y colinas .pdfgiriraj65
 
68 Exercise Ferris Corporation makes a single product a f.pdf
68 Exercise Ferris Corporation makes a single product  a f.pdf68 Exercise Ferris Corporation makes a single product  a f.pdf
68 Exercise Ferris Corporation makes a single product a f.pdfgiriraj65
 
A special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdfA special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdfgiriraj65
 

More from giriraj65 (20)

Which of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdfWhich of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdf
 
Wheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdfWheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdf
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
 
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdfTableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
 
Rios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdfRios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdf
 
Question 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdfQuestion 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdf
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdf
 
Problem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdfProblem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdf
 
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdfPLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdf
 
Please discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdfPlease discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdf
 
Mill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdfMill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdf
 
For each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdfFor each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdf
 
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1  Geor.pdfExercise I Georgettes and Georges Genotypes Gene 1  Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdf
 
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdfEl 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
 
Ests realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdfEsts realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdf
 
Assume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdfAssume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdf
 
a How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdfa How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdf
 
A Bucle remolino y arco B Crestas surcos y colinas .pdf
A  Bucle remolino y arco   B  Crestas surcos y colinas  .pdfA  Bucle remolino y arco   B  Crestas surcos y colinas  .pdf
A Bucle remolino y arco B Crestas surcos y colinas .pdf
 
68 Exercise Ferris Corporation makes a single product a f.pdf
68 Exercise Ferris Corporation makes a single product  a f.pdf68 Exercise Ferris Corporation makes a single product  a f.pdf
68 Exercise Ferris Corporation makes a single product a f.pdf
 
A special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdfA special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdf
 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

The resto txt Use for TM254 2021J TMA02 Question 6 .pdf

  • 1. The resto txt: /* Use for TM254 2021J, TMA02, Question 6 Copyright 2021 The Open University */ /* Note - all dates are in 'YYYY-MM-DD' format */ /* This overrides the date format set by the local PC locale variable. */ GRANT USAGE ON SCHEMA public TO PUBLIC; GRANT ALL ON SCHEMA public TO PUBLIC; /* Evaluate/Run this file in the default database, postgres, and as the*/ /* default user, postgres. */ /* If you re-run the file you will reset any changes you have made to */ /* the database content back to the original content. */ /* The DROP IF EXISTS ensures that when you re-run the script file it */ /* replaces the content of the database, on first run the tables and */ /* domains don't exist so are not dropped and you recieve a warning */ /* message. */ DROP VIEW IF EXISTS Catalogue CASCADE; DROP TABLE IF EXISTS TaskTicket CASCADE; DROP TABLE IF EXISTS HasExpertiseIn CASCADE; DROP TABLE IF EXISTS RestorationItem CASCADE; DROP TABLE IF EXISTS Expert CASCADE; DROP TABLE IF EXISTS Specialism CASCADE; DROP DOMAIN IF EXISTS ItemCodes; DROP DOMAIN IF EXISTS DescriptionString; DROP DOMAIN IF EXISTS TaskNumbers; DROP DOMAIN IF EXISTS NameString; DROP DOMAIN IF EXISTS AddressString; DROP DOMAIN IF EXISTS PublicityString; DROP DOMAIN IF EXISTS EmailString; DROP DOMAIN IF EXISTS YN; DROP DOMAIN IF EXISTS SpecialismString; DROP DOMAIN IF EXISTS QualificationsString; DROP DOMAIN IF EXISTS MonetaryValues;
  • 2. /* Now creating the domains */ CREATE DOMAIN ItemCodes AS INTEGER CHECK(VALUE > 0); CREATE DOMAIN DescriptionString AS VARCHAR(120); CREATE DOMAIN TaskNumbers AS INTEGER CHECK(VALUE > 0); CREATE DOMAIN NameString AS VARCHAR(120); CREATE DOMAIN AddressString AS VARCHAR(400); CREATE DOMAIN PublicityString AS VARCHAR(120); CREATE DOMAIN EmailString AS VARCHAR(100) CHECK (VALUE LIKE ('%@%')); CREATE DOMAIN YN AS CHAR(1) CHECK(VALUE IN ('Y','N') ); CREATE DOMAIN SpecialismString AS VARCHAR(120); CREATE DOMAIN QualificationsString AS VARCHAR(300); CREATE DOMAIN MonetaryValues AS NUMERIC(9,2) CHECK (VALUE >= 0.00); /* DOMAINS CREATED */ /* now creating tables */ CREATE TABLE Specialism( Name SpecialismString PRIMARY KEY ); CREATE TABLE RestorationItem( ItemCode ItemCodes PRIMARY KEY, ItemDescription DescriptionString NOT NULL, WorkDescription DescriptionString NOT NULL, InsuranceValue MonetaryValues, CostEstimate MonetaryValues NOT NULL, DateAccepted DATE NOT NULL, DateReturned DATE, PriceCharged MonetaryValues, -- relationship Requires mandatory participation -- WARNING - the requires mandatory participation -- constraint has not been implemented. -- This omission permits the entry of a row that -- does not match a related TaskTicket record. -- CONSTRAINT RequiresMandatory CHECK (ItemCode -- IN (SELECT ItemCode FROM TaskTicket)) CONSTRAINT ValueAcceptanceDate CHECK (DateAccepted <= CURRENT_DATE), CONSTRAINT DateOrderCheck CHECK (DateReturned > DateAccepted), CONSTRAINT ValidInsuranceValue CHECK (InsuranceValue <= 1000000.00)
  • 3. ); CREATE TABLE Expert( Name NameString PRIMARY KEY, Address AddressString NOT NULL, PublicityText PublicityString, Email EmailString NOT NULL, UseInExternalCatalogue YN NOT NULL, DateApprovedUse DATE NOT NULL, -- relationship HasExpertiseIn mandatory participation -- WARNING - the HasExpertiseIn mandatory participation -- constraint has not been implemented. -- This omission permits the entry of a row that -- does not match a related HasExpertiseIn record. -- CONSTRAINT HasExpertiseInMandatory CHECK (Name -- IN (SELECT ExpertName FROM HasExpertiseIn)) CONSTRAINT DateApprovedUseValid CHECK (DateApprovedUse <= CURRENT_DATE) ); CREATE TABLE HasExpertiseIn( ExpertName NameString, SpecialismName SpecialismString, PRIMARY KEY(ExpertName,SpecialismName), ChargeRate MonetaryValues NOT NULL, QualificationsHeld QualificationsString, CONSTRAINT ExpertHasExpertiseIn FOREIGN KEY (ExpertName) REFERENCES Expert, CONSTRAINT HasExpertiseInSpecialism FOREIGN KEY (SpecialismName) REFERENCES Specialism ); CREATE TABLE TaskTicket( TaskNumber TaskNumbers PRIMARY KEY, Description DescriptionString NOT NULL, SpecialismNeeded SpecialismString NOT NULL, DateCreated DATE NOT NULL, DateCompleted DATE, CostOfParts MonetaryValues,
  • 4. CostOflabour MonetaryValues, ItemCode ItemCodes NOT NULL, Name NameString, CONSTRAINT Needs FOREIGN KEY (SpecialismNeeded) REFERENCES Specialism, CONSTRAINT Requires FOREIGN KEY (ItemCode) REFERENCES RestorationItem, CONSTRAINT WorkedOnBy FOREIGN KEY (Name) REFERENCES Expert, CONSTRAINT DateCreatedValidity CHECK ( DateCreated <= CURRENT_DATE ), CONSTRAINT DateSequenceValidity CHECK ( DateCompleted >= DateCreated ) ); /* TABLES CREATED */ /* now to populate the tables with data */ INSERT INTO Specialism VALUES ('Clockwork Toys'); INSERT INTO Specialism VALUES ('Clocks'); INSERT INTO Specialism VALUES ('Lighting'); INSERT INTO Specialism VALUES ('Electrical Items'); INSERT INTO Specialism VALUES ('Taxidermy'); INSERT INTO Specialism VALUES ('Tractors'); INSERT INTO Specialism VALUES ('Painting - small scale'); INSERT INTO Specialism VALUES ('Painting - large scale'); INSERT INTO Specialism VALUES ('Stationary Engines, pre-1940'); INSERT INTO Specialism VALUES ('Model Trains - all scales'); INSERT INTO Specialism VALUES ('Lawnmowers pre-1960'); INSERT INTO Specialism VALUES ('Model Steamboats'); INSERT INTO Specialism VALUES ('Welding'); INSERT INTO Specialism VALUES ('Metal Fabrication'); INSERT INTO Specialism VALUES ('Fabric restoration'); INSERT INTO Specialism VALUES ('Woodworking'); INSERT INTO Expert VALUES('Bob','Sunflower Valley','Fixing it since 1999.','bob@theyard','Y','2022-02-01'); INSERT INTO Expert VALUES('Wendy','Fixham Harbour',NULL, 'wendy@harbourview','Y','2022-01-04'); INSERT INTO Expert VALUES('Pilchard','Sunflower Valley','All era, all fabrics, no job too small.','PT6@sunflowermail','N','2022-02-13'); INSERT INTO Expert VALUES('Leo','Campus Lane','Trains a speciality, also clocks and clockwork toys.','LeoR12@TheCampus','Y','2022-01-19'); INSERT INTO Expert VALUES('Spud','Pickles Field','All things
  • 5. steam.','strawman@valley','Y','2022-05-17'); INSERT INTO Expert VALUES('Anish','Ancient Hollow','Restoration paintwork, toys and small engines a speciality.','digdig@oldground','N','2022-05-11'); INSERT INTO Expert VALUES('Benjamin','The Post Office','Fabrication and welding - no job too big.','postie1@sortingyard','Y','2022-04-10'); INSERT INTO Expert VALUES('JJ','Spring City','Small scale traction and stationary engines, repair and refurbishment, call for a quote.','rocket23@SpringCityRockets','Y','2022-05-13'); INSERT INTO Expert VALUES('Angelo','Bobsville Pizzeria','Lighting them up since 1999.','Angelo@bakersfield','N','2022-03-02'); INSERT INTO Expert VALUES('Saffron','Pickles Sunflower Factory','Farm machinery repairs.','Saff@Pickles','Y','2022-03-10'); INSERT INTO HasExpertiseIn VALUES ('Bob','Welding',23.00,'City&Guilds, Level 3 welding,2021'); INSERT INTO HasExpertiseIn VALUES ('Wendy','Fabric restoration',10.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Pilchard','Fabric restoration',14.00,'Advanced UFT, 2019'); INSERT INTO HasExpertiseIn VALUES ('Pilchard','Taxidermy',25.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Leo','Model Trains - all scales',35.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Leo','Clocks',18.00,'BHI Technician Grade, 2019'); INSERT INTO HasExpertiseIn VALUES ('Leo', 'Clockwork Toys',15.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Spud', 'Model Steamboats',15.50,NULL); INSERT INTO HasExpertiseIn VALUES ('Spud', 'Stationary Engines, pre-1940',23.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Spud','Metal Fabrication',20.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Spud', 'Tractors',18.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Anish', 'Painting - small scale',16.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Anish', 'Painting - large scale',23.00,'Vehicle body and paint - level 2 apprenticeship'); INSERT INTO HasExpertiseIn VALUES ('Anish', 'Clockwork Toys',17.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Benjamin','Metal Fabrication',19.00,'Fundamentals of Metal Fabrication Certificate, 2010'); INSERT INTO HasExpertiseIn VALUES ('Benjamin', 'Welding',22.00,'3G MIG Welding, 2020'); INSERT INTO HasExpertiseIn VALUES ('Benjamin', 'Woodworking',18.00,NULL); INSERT INTO HasExpertiseIn VALUES ('JJ','Stationary Engines, pre-1940',26.00,NULL); INSERT INTO HasExpertiseIn VALUES ('JJ','Metal Fabrication',18.00, 'Advanced of Metal Fabrication Certificate, 2011'); INSERT INTO HasExpertiseIn VALUES ('Angelo','Lighting',19.00,'LIA Certificate - Advanced'); INSERT INTO HasExpertiseIn VALUES ('Angelo','Electrical Items',19.00,'Part P 2393-10'); INSERT INTO HasExpertiseIn VALUES ('Saffron','Tractors',22.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Saffron', 'Metal Fabrication',17.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Saffron','Welding',21.90,'MIG/MAG, TIG and MMA, ASME IX, TWI, 2020');
  • 6. INSERT INTO HasExpertiseIn VALUES ('Saffron','Stationary Engines, pre-1940',26.00,NULL); INSERT INTO RestorationItem VALUES(291,'Ratchet Seed spreader','Straighten ratchet, replace handle',80.00,15.00,'2022-05-01','2022-05-20',55.00); INSERT INTO RestorationItem VALUES(101,'Dentist drill, 1940','Improve look', 100.00, 60.00,'2022-05-01','2022-05-22',66.00); INSERT INTO RestorationItem VALUES(524,'Sir Nigel Gresley, BR Blue, Hattons Original','Align bogies',900.00,25.00,'2022-04-20','2022-04-30',25.00 ); INSERT INTO RestorationItem VALUES(118,'Chandelier, 200 drop, 6ft diameter, plain','repair and replace missing elements',870.00,80.00,'2022-04-01',NULL,NULL ); INSERT INTO RestorationItem VALUES(293,'Lister D Type single cylinder petrol engine built Sept 1946','Ensure running and fit to wheeled trailer',400.00,690.00,'2022-05-02','2022-05-18',660.00 ); INSERT INTO RestorationItem VALUES(249,'1928 Ruston Hornby and bamford cornmill','Redress flywheel, repaint',1500.00,400.00,'2022-03-25','2022-04-15',280.00 ); INSERT INTO RestorationItem VALUES(483,'BAMFORD OPEN CRANK, 1933','try to get running',300.00, 600.00,'2022-02-02','2022-3-10',630.00); INSERT INTO RestorationItem VALUES(884,'TIN PLATE WIND UP SPEEDBOAT SCHYLLING COLLECTOR SERIES','lossen tight spring, make new key',NULL,60.00,'2022-02-17' ,'2022-03- 10',80.00); INSERT INTO RestorationItem VALUES(937,'Schuco Clockwork Pecking Bird','re- feather',NULL,30.50,'2022-04-28',NULL,NULL ); INSERT INTO RestorationItem VALUES(867,'Wind-Up Walking Turkey, Blomer & Scholer, US Zone Germany, 50s.','repaint and reattach foot',100.00,60.00,'2022-03-15','2022-04-05',80.00 ); INSERT INTO RestorationItem VALUES(239,'Foster 4" scale Traction Engine','Make boiler good for steam',20000.00,1550.00,'2022-04-21',NULL,NULL ); INSERT INTO RestorationItem VALUES(845,'Steam Chair-o-plane, 1910 by Walkers of Tewkesbury','refit chairs, re-upholster in vintage fabrics',400000.00,5000.00,'2022-01-05','2022- 02-15',2050.00); INSERT INTO RestorationItem VALUES(224,'Lotus Elan Fuel Gauge, BF2201','re-chrome',NULL, 60.00,'2022-02-27','2022-03-15',100.00 ); INSERT INTO RestorationItem VALUES(163,'Asco Counter Scales, sweet shop','re-balance', NULL, 25.00,'2022-03-20','2022-04-04',30.00 ); INSERT INTO RestorationItem VALUES(246,'Victorian Brass Postal Scales with Mahogany Base','replace missing crossrod',100.00,30.00,'2022-03-23','2022-04-14',80.00 ); INSERT INTO RestorationItem VALUES(934,'Ransomes Mg2 Crawler Tractor','retread and clear oil residue',500.00, 1500.00,'2022-01-02','2022-01-31',1800.00 ); INSERT INTO RestorationItem VALUES(468,'Oxford Allen Scythe, Villiers 4 stroke engine grass mower cutter brush finger bar','Address finger bar alignment',100.00,30.00,'2022-03-19','2022-03- 29',30.00 ); INSERT INTO RestorationItem VALUES(835,'Plough and ridger','replace plough blade, repaint in original colours',400.00,350.00,'2022-03-24','2022-04-25',350.00); INSERT INTO RestorationItem VALUES(348,'Corn mill grinder, 16inch spindle','re-box corn
  • 7. holder',250.00,100.00,'2022-01-20','2022-02-15',200.00 ); INSERT INTO RestorationItem VALUES(783,'Vintage Antique poss Victorian Rotary Knife Cleaner Sharpener - premier', 'trim sharpening wheel, re-varnish',200.00,100.00,'2022-03-15',NULL,NULL ); INSERT INTO RestorationItem VALUES(359,'63inch Gents Railway Station Factory Clock','fit new hands',5000.00,250.00,'2022-03-12','2022-03-30',110.00 ); INSERT INTO TaskTicket VALUES(100, 'Straighten ratchet','Metal Fabrication','2022-05-02', '2022-05-06',0.00,28.00,291,'JJ'); INSERT INTO TaskTicket VALUES(101, 'Replace handle','Woodworking','2022-05-02', '2022-05- 09',5.00,22.00,291,'Benjamin'); INSERT INTO TaskTicket VALUES(102, 'Check and refurbish electricals','Electrical Items','2022-05-02', '2022-05-04',12.00,16.00,101,'Angelo'); INSERT INTO TaskTicket VALUES(103, 'Restore paintwork','Painting - small scale','2022-05-06', '2022-05-09',18.00,20.00,101,'Anish'); INSERT INTO TaskTicket VALUES(104, 'Align bogies','Model Trains - all scales','2022-04-21','2022-04-29',0.00,20.00,524,'Leo'); INSERT INTO TaskTicket VALUES(105, 'Repair and replace missing elements','Lighting','2022-04-03',NULL,NULL,NULL,118,'Angelo'); INSERT INTO TaskTicket VALUES(106, 'Ensure running','Stationary Engines, pre- 1940','2022-05-02', '2022-05-06' ,80.00,140.00,293,'Saffron'); INSERT INTO TaskTicket VALUES(107, 'Construct chassis','Metal Fabrication','2022-05-02','2022-05-05',110.00,200.00,293,'Spud'); INSERT INTO TaskTicket VALUES(108, 'Construct trolley on chassis','Woodworking','2022-05-10','2022-05-18',50.00,83.00,293,'Benjamin'); INSERT INTO TaskTicket VALUES(109, 'Redress fly-wheel','Stationary Engines, pre- 1940','2022-03-26','2022-03-29',10.00,23.00,249,'Saffron'); INSERT INTO TaskTicket VALUES(110, 'Repaint','Painting - large scale','2022-03-30','2022-04- 05',105.00,88.00,249,'Anish'); INSERT INTO TaskTicket VALUES(111, 'Overhaul to working state','Stationary Engines, pre- 1940','2022-02-04','2022-02-27',377.00,238.00,483,'Spud'); INSERT INTO TaskTicket VALUES(112, 'Loosen tight spring','Clockwork Toys','2022-02-18','2022- 02-21', 0.00, 40.00,884,'Leo'); INSERT INTO TaskTicket VALUES(113, 'Make new key','Clockwork Toys','2022-02-18','2022-02-
  • 8. 28',5.00,30.00,884,'Leo'); INSERT INTO TaskTicket VALUES(114, 'Re-feather','Taxidermy','2022-04-28',NULL, NULL,NULL,937,'Pilchard'); INSERT INTO TaskTicket VALUES(115, 'Re-attach foot','Clockwork Toys','2022-03-20','2022-03- 22', 5.00, 20.00,867,'Anish'); INSERT INTO TaskTicket VALUES(116, 'Repaint','Painting - small scale','2022-03-23','2022-03- 29',25.00,25.00,867,'Anish'); INSERT INTO TaskTicket VALUES(117, 'Construct replacement for damaged boiler plates','Metal Fabrication','2022-04-22',NULL,NULL,NULL,239,'Benjamin'); INSERT INTO TaskTicket VALUES(118, 'Weld new boiler plates','Welding','2022-04-28',NULL,NULL,NULL,239,'Benjamin'); INSERT INTO TaskTicket VALUES(119, 'Paint boiler','Painting - large scale','2022-04-30',NULL,NULL,NULL,239,'Anish'); INSERT INTO TaskTicket VALUES(120, 'Replace missing chairs','Woodworking','2022-01-05','2022-01-13', 250.00,240.00 ,845,'Benjamin'); INSERT INTO TaskTicket VALUES(121, 'Re-upholster all chairs in vintage fabrics','Fabric restoration','2022-01-15','2022-01-30', 400.00,340.00,845,'Wendy'); INSERT INTO TaskTicket VALUES(122, 'Attach chairs replacing chains as required','Metal Fabrication','2022-01-31','2022-02-10', 180.00,100.00,845,'Spud'); INSERT INTO TaskTicket VALUES(123, 'Rechrome','Painting - small scale','2022-02-28','2022-03- 12', 40.00,40.00,224,'Anish'); INSERT INTO TaskTicket VALUES(124, 'Rebalance scale','Clockwork Toys','2022-03-22','2022- 03-29', 3.00, 20.00,163,'Anish'); INSERT INTO TaskTicket VALUES(125, 'Replace missing cross-rod','Metal Fabrication','2022-03-26','2022-03-30', 30.00, 35.00,246,'Spud'); INSERT INTO TaskTicket VALUES(126, 'Retread','Tractors','2022-01-03','2022-01- 18',340.00,120.00 ,934,'Saffron'); INSERT INTO TaskTicket VALUES(127, 'Refurbish engine','Tractors','2022-01-08','2022-01- 26',430.00, 550.00,934,'Saffron'); INSERT INTO TaskTicket VALUES(128, 'Align finger bars','Metal Fabrication','2022-03-19','2022- 03-21', 0.00, 23.00,468,'JJ'); INSERT INTO TaskTicket VALUES(129, 'Replace plough blade','Metal Fabrication','2022-03-25','2022-03-28',70.00, 35.00,835,'Saffron');
  • 9. INSERT INTO TaskTicket VALUES(130, 'Repaint with matching original colours','Painting - large scale','2022-03-29','2022-04-15', 105.00, 95.00,835,'Anish'); INSERT INTO TaskTicket VALUES(131, 'Replace corn holder using Oak','Woodworking','2022-01-20','2022-01-29', 80.00, 100.00,348,'Benjamin'); INSERT INTO TaskTicket VALUES(132, 'Trim sharpening wheel','Metal Fabrication','2022-03-16',NULL, NULL,NULL,783,'Spud'); INSERT INTO TaskTicket VALUES(133, 'Re-varnish','Painting - small scale','2022-03-25',NULL, NULL,NULL,783,'Anish' ); INSERT INTO TaskTicket VALUES(134, 'Fit new hands','Metal Fabrication','2022-03-16','2022-03- 22',30.00, 40.00,359,'JJ' ); /* Data input ends */ /* Use for TM254 2021J, TMA02, Question 6 Copyright 2021 The Open University */ /* Note - all dates are in 'YYYY-MM-DD' format */ /* This overrides the date format set by the local PC locale variable. */ GRANT USAGE ON SCHEMA public TO PUBLIC; GRANT ALL ON SCHEMA public TO PUBLIC; /* Evaluate/Run this file in the default database, postgres, and as the*/ /* default user, postgres. */ /* If you re-run the file you will reset any changes you have made to */ /* the database content back to the original content. */ /* The DROP IF EXISTS ensures that when you re-run the script file it */ /* replaces the content of the database, on first run the tables and */ /* domains don't exist so are not dropped and you recieve a warning */ /* message. */
  • 10. DROP VIEW IF EXISTS Catalogue CASCADE; DROP TABLE IF EXISTS TaskTicket CASCADE; DROP TABLE IF EXISTS HasExpertiseIn CASCADE; DROP TABLE IF EXISTS RestorationItem CASCADE; DROP TABLE IF EXISTS Expert CASCADE; DROP TABLE IF EXISTS Specialism CASCADE; DROP DOMAIN IF EXISTS ItemCodes; DROP DOMAIN IF EXISTS DescriptionString; DROP DOMAIN IF EXISTS TaskNumbers; DROP DOMAIN IF EXISTS NameString; DROP DOMAIN IF EXISTS AddressString; DROP DOMAIN IF EXISTS PublicityString; DROP DOMAIN IF EXISTS EmailString; DROP DOMAIN IF EXISTS YN; DROP DOMAIN IF EXISTS SpecialismString; DROP DOMAIN IF EXISTS QualificationsString; DROP DOMAIN IF EXISTS MonetaryValues; /* Now creating the domains */ CREATE DOMAIN ItemCodes AS INTEGER CHECK(VALUE > 0);
  • 11. CREATE DOMAIN DescriptionString AS VARCHAR(120); CREATE DOMAIN TaskNumbers AS INTEGER CHECK(VALUE > 0); CREATE DOMAIN NameString AS VARCHAR(120); CREATE DOMAIN AddressString AS VARCHAR(400); CREATE DOMAIN PublicityString AS VARCHAR(120); CREATE DOMAIN EmailString AS VARCHAR(100) CHECK (VALUE LIKE ('%@%')); CREATE DOMAIN YN AS CHAR(1) CHECK(VALUE IN ('Y','N') ); CREATE DOMAIN SpecialismString AS VARCHAR(120); CREATE DOMAIN QualificationsString AS VARCHAR(300); CREATE DOMAIN MonetaryValues AS NUMERIC(9,2) CHECK (VALUE >= 0.00); /* DOMAINS CREATED */ /* now creating tables */ CREATE TABLE Specialism( Name SpecialismString PRIMARY KEY ); CREATE TABLE RestorationItem( ItemCode ItemCodes PRIMARY KEY, ItemDescription DescriptionString NOT NULL, WorkDescription DescriptionString NOT NULL, InsuranceValue MonetaryValues,
  • 12. CostEstimate MonetaryValues NOT NULL, DateAccepted DATE NOT NULL, DateReturned DATE, PriceCharged MonetaryValues, -- relationship Requires mandatory participation -- WARNING - the requires mandatory participation -- constraint has not been implemented. -- This omission permits the entry of a row that -- does not match a related TaskTicket record. -- CONSTRAINT RequiresMandatory CHECK (ItemCode -- IN (SELECT ItemCode FROM TaskTicket)) CONSTRAINT ValueAcceptanceDate CHECK (DateAccepted <= CURRENT_DATE), CONSTRAINT DateOrderCheck CHECK (DateReturned > DateAccepted), CONSTRAINT ValidInsuranceValue CHECK (InsuranceValue <= 1000000.00) ); CREATE TABLE Expert( Name NameString PRIMARY KEY, Address AddressString NOT NULL, PublicityText PublicityString,
  • 13. Email EmailString NOT NULL, UseInExternalCatalogue YN NOT NULL, DateApprovedUse DATE NOT NULL, -- relationship HasExpertiseIn mandatory participation -- WARNING - the HasExpertiseIn mandatory participation -- constraint has not been implemented. -- This omission permits the entry of a row that -- does not match a related HasExpertiseIn record. -- CONSTRAINT HasExpertiseInMandatory CHECK (Name -- IN (SELECT ExpertName FROM HasExpertiseIn)) CONSTRAINT DateApprovedUseValid CHECK (DateApprovedUse <= CURRENT_DATE) ); CREATE TABLE HasExpertiseIn( ExpertName NameString, SpecialismName SpecialismString, PRIMARY KEY(ExpertName,SpecialismName), ChargeRate MonetaryValues NOT NULL, QualificationsHeld QualificationsString, CONSTRAINT ExpertHasExpertiseIn FOREIGN KEY (ExpertName) REFERENCES Expert,
  • 14. CONSTRAINT HasExpertiseInSpecialism FOREIGN KEY (SpecialismName) REFERENCES Specialism ); CREATE TABLE TaskTicket( TaskNumber TaskNumbers PRIMARY KEY, Description DescriptionString NOT NULL, SpecialismNeeded SpecialismString NOT NULL, DateCreated DATE NOT NULL, DateCompleted DATE, CostOfParts MonetaryValues, CostOflabour MonetaryValues, ItemCode ItemCodes NOT NULL, Name NameString, CONSTRAINT Needs FOREIGN KEY (SpecialismNeeded) REFERENCES Specialism, CONSTRAINT Requires FOREIGN KEY (ItemCode) REFERENCES RestorationItem, CONSTRAINT WorkedOnBy FOREIGN KEY (Name) REFERENCES Expert, CONSTRAINT DateCreatedValidity CHECK ( DateCreated <= CURRENT_DATE ), CONSTRAINT DateSequenceValidity CHECK ( DateCompleted >= DateCreated ) );
  • 15. /* TABLES CREATED */ /* now to populate the tables with data */ INSERT INTO Specialism VALUES ('Clockwork Toys'); INSERT INTO Specialism VALUES ('Clocks'); INSERT INTO Specialism VALUES ('Lighting'); INSERT INTO Specialism VALUES ('Electrical Items'); INSERT INTO Specialism VALUES ('Taxidermy'); INSERT INTO Specialism VALUES ('Tractors'); INSERT INTO Specialism VALUES ('Painting - small scale'); INSERT INTO Specialism VALUES ('Painting - large scale'); INSERT INTO Specialism VALUES ('Stationary Engines, pre-1940'); INSERT INTO Specialism VALUES ('Model Trains - all scales'); INSERT INTO Specialism VALUES ('Lawnmowers pre-1960'); INSERT INTO Specialism VALUES ('Model Steamboats'); INSERT INTO Specialism VALUES ('Welding'); INSERT INTO Specialism VALUES ('Metal Fabrication'); INSERT INTO Specialism VALUES ('Fabric restoration'); INSERT INTO Specialism VALUES ('Woodworking'); INSERT INTO Expert VALUES('Bob','Sunflower Valley','Fixing it since 1999.','bob@theyard','Y','2022-02-01'); INSERT INTO Expert VALUES('Wendy','Fixham Harbour',NULL,
  • 16. 'wendy@harbourview','Y','2022-01-04'); INSERT INTO Expert VALUES('Pilchard','Sunflower Valley','All era, all fabrics, no job too small.','PT6@sunflowermail','N','2022-02-13'); INSERT INTO Expert VALUES('Leo','Campus Lane','Trains a speciality, also clocks and clockwork toys.','LeoR12@TheCampus','Y','2022-01-19'); INSERT INTO Expert VALUES('Spud','Pickles Field','All things steam.','strawman@valley','Y','2022-05-17'); INSERT INTO Expert VALUES('Anish','Ancient Hollow','Restoration paintwork, toys and small engines a speciality.','digdig@oldground','N','2022-05-11'); INSERT INTO Expert VALUES('Benjamin','The Post Office','Fabrication and welding - no job too big.','postie1@sortingyard','Y','2022-04-10'); INSERT INTO Expert VALUES('JJ','Spring City','Small scale traction and stationary engines, repair and refurbishment, call for a quote.','rocket23@SpringCityRockets','Y','2022-05-13'); INSERT INTO Expert VALUES('Angelo','Bobsville Pizzeria','Lighting them up since 1999.','Angelo@bakersfield','N','2022-03-02'); INSERT INTO Expert VALUES('Saffron','Pickles Sunflower Factory','Farm machinery repairs.','Saff@Pickles','Y','2022-03-10'); INSERT INTO HasExpertiseIn VALUES ('Bob','Welding',23.00,'City&Guilds, Level 3 welding,2021'); INSERT INTO HasExpertiseIn VALUES ('Wendy','Fabric restoration',10.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Pilchard','Fabric restoration',14.00,'Advanced UFT, 2019'); INSERT INTO HasExpertiseIn VALUES ('Pilchard','Taxidermy',25.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Leo','Model Trains - all scales',35.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Leo','Clocks',18.00,'BHI Technician Grade, 2019'); INSERT INTO HasExpertiseIn VALUES ('Leo', 'Clockwork Toys',15.00,NULL);
  • 17. INSERT INTO HasExpertiseIn VALUES ('Spud', 'Model Steamboats',15.50,NULL); INSERT INTO HasExpertiseIn VALUES ('Spud', 'Stationary Engines, pre-1940',23.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Spud','Metal Fabrication',20.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Spud', 'Tractors',18.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Anish', 'Painting - small scale',16.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Anish', 'Painting - large scale',23.00,'Vehicle body and paint - level 2 apprenticeship'); INSERT INTO HasExpertiseIn VALUES ('Anish', 'Clockwork Toys',17.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Benjamin','Metal Fabrication',19.00,'Fundamentals of Metal Fabrication Certificate, 2010'); INSERT INTO HasExpertiseIn VALUES ('Benjamin', 'Welding',22.00,'3G MIG Welding, 2020'); INSERT INTO HasExpertiseIn VALUES ('Benjamin', 'Woodworking',18.00,NULL); INSERT INTO HasExpertiseIn VALUES ('JJ','Stationary Engines, pre-1940',26.00,NULL); INSERT INTO HasExpertiseIn VALUES ('JJ','Metal Fabrication',18.00, 'Advanced of Metal Fabrication Certificate, 2011'); INSERT INTO HasExpertiseIn VALUES ('Angelo','Lighting',19.00,'LIA Certificate - Advanced'); INSERT INTO HasExpertiseIn VALUES ('Angelo','Electrical Items',19.00,'Part P 2393-10'); INSERT INTO HasExpertiseIn VALUES ('Saffron','Tractors',22.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Saffron', 'Metal Fabrication',17.00,NULL); INSERT INTO HasExpertiseIn VALUES ('Saffron','Welding',21.90,'MIG/MAG, TIG and MMA, ASME IX, TWI, 2020'); INSERT INTO HasExpertiseIn VALUES ('Saffron','Stationary Engines, pre-1940',26.00,NULL);
  • 18. INSERT INTO RestorationItem VALUES(291,'Ratchet Seed spreader','Straighten ratchet, replace handle',80.00,15.00,'2022-05-01','2022-05-20',55.00); INSERT INTO RestorationItem VALUES(101,'Dentist drill, 1940','Improve look', 100.00, 60.00,'2022-05-01','2022-05-22',66.00); INSERT INTO RestorationItem VALUES(524,'Sir Nigel Gresley, BR Blue, Hattons Original','Align bogies',900.00,25.00,'2022-04-20','2022-04-30',25.00 ); INSERT INTO RestorationItem VALUES(118,'Chandelier, 200 drop, 6ft diameter, plain','repair and replace missing elements',870.00,80.00,'2022-04-01',NULL,NULL ); INSERT INTO RestorationItem VALUES(293,'Lister D Type single cylinder petrol engine built Sept 1946','Ensure running and fit to wheeled trailer',400.00,690.00,'2022-05-02','2022-05-18',660.00 ); INSERT INTO RestorationItem VALUES(249,'1928 Ruston Hornby and bamford cornmill','Redress flywheel, repaint',1500.00,400.00,'2022-03-25','2022-04-15',280.00 ); INSERT INTO RestorationItem VALUES(483,'BAMFORD OPEN CRANK, 1933','try to get running',300.00, 600.00,'2022-02-02','2022-3-10',630.00); INSERT INTO RestorationItem VALUES(884,'TIN PLATE WIND UP SPEEDBOAT SCHYLLING COLLECTOR SERIES','lossen tight spring, make new key',NULL,60.00,'2022-02-17' ,'2022-03- 10',80.00); INSERT INTO RestorationItem VALUES(937,'Schuco Clockwork Pecking Bird','re- feather',NULL,30.50,'2022-04-28',NULL,NULL ); INSERT INTO RestorationItem VALUES(867,'Wind-Up Walking Turkey, Blomer & Scholer, US Zone Germany, 50s.','repaint and reattach foot',100.00,60.00,'2022-03-15','2022-04-05',80.00 ); INSERT INTO RestorationItem VALUES(239,'Foster 4" scale Traction Engine','Make boiler good for steam',20000.00,1550.00,'2022-04-21',NULL,NULL ); INSERT INTO RestorationItem VALUES(845,'Steam Chair-o-plane, 1910 by Walkers of Tewkesbury','refit chairs, re-upholster in vintage fabrics',400000.00,5000.00,'2022-01-05','2022- 02-15',2050.00); INSERT INTO RestorationItem VALUES(224,'Lotus Elan Fuel Gauge, BF2201','re-chrome',NULL, 60.00,'2022-02-27','2022-03-15',100.00 ); INSERT INTO RestorationItem VALUES(163,'Asco Counter Scales, sweet shop','re-balance',
  • 19. NULL, 25.00,'2022-03-20','2022-04-04',30.00 ); INSERT INTO RestorationItem VALUES(246,'Victorian Brass Postal Scales with Mahogany Base','replace missing crossrod',100.00,30.00,'2022-03-23','2022-04-14',80.00 ); INSERT INTO RestorationItem VALUES(934,'Ransomes Mg2 Crawler Tractor','retread and clear oil residue',500.00, 1500.00,'2022-01-02','2022-01-31',1800.00 ); INSERT INTO RestorationItem VALUES(468,'Oxford Allen Scythe, Villiers 4 stroke engine grass mower cutter brush finger bar','Address finger bar alignment',100.00,30.00,'2022-03-19','2022-03- 29',30.00 ); INSERT INTO RestorationItem VALUES(835,'Plough and ridger','replace plough blade, repaint in original colours',400.00,350.00,'2022-03-24','2022-04-25',350.00); INSERT INTO RestorationItem VALUES(348,'Corn mill grinder, 16inch spindle','re-box corn holder',250.00,100.00,'2022-01-20','2022-02-15',200.00 ); INSERT INTO RestorationItem VALUES(783,'Vintage Antique poss Victorian Rotary Knife Cleaner Sharpener - premier', 'trim sharpening wheel, re-varnish',200.00,100.00,'2022-03-15',NULL,NULL ); INSERT INTO RestorationItem VALUES(359,'63inch Gents Railway Station Factory Clock','fit new hands',5000.00,250.00,'2022-03-12','2022-03-30',110.00 ); INSERT INTO TaskTicket VALUES(100, 'Straighten ratchet','Metal Fabrication','2022-05-02', '2022-05-06',0.00,28.00,291,'JJ'); INSERT INTO TaskTicket VALUES(101, 'Replace handle','Woodworking','2022-05-02', '2022-05- 09',5.00,22.00,291,'Benjamin'); INSERT INTO TaskTicket VALUES(102, 'Check and refurbish electricals','Electrical Items','2022-05-02', '2022-05-04',12.00,16.00,101,'Angelo'); INSERT INTO TaskTicket VALUES(103, 'Restore paintwork','Painting - small scale','2022-05-06', '2022-05-09',18.00,20.00,101,'Anish'); INSERT INTO TaskTicket VALUES(104, 'Align bogies','Model Trains - all
  • 20. scales','2022-04-21','2022-04-29',0.00,20.00,524,'Leo'); INSERT INTO TaskTicket VALUES(105, 'Repair and replace missing elements','Lighting','2022-04-03',NULL,NULL,NULL,118,'Angelo'); INSERT INTO TaskTicket VALUES(106, 'Ensure running','Stationary Engines, pre- 1940','2022-05-02', '2022-05-06' ,80.00,140.00,293,'Saffron'); INSERT INTO TaskTicket VALUES(107, 'Construct chassis','Metal Fabrication','2022-05-02','2022-05-05',110.00,200.00,293,'Spud'); INSERT INTO TaskTicket VALUES(108, 'Construct trolley on chassis','Woodworking','2022-05-10','2022-05-18',50.00,83.00,293,'Benjamin'); INSERT INTO TaskTicket VALUES(109, 'Redress fly-wheel','Stationary Engines, pre- 1940','2022-03-26','2022-03-29',10.00,23.00,249,'Saffron'); INSERT INTO TaskTicket VALUES(110, 'Repaint','Painting - large scale','2022-03-30','2022-04- 05',105.00,88.00,249,'Anish'); INSERT INTO TaskTicket VALUES(111, 'Overhaul to working state','Stationary Engines, pre- 1940','2022-02-04','2022-02-27',377.00,238.00,483,'Spud'); INSERT INTO TaskTicket VALUES(112, 'Loosen tight spring','Clockwork Toys','2022-02-18','2022- 02-21', 0.00, 40.00,884,'Leo'); INSERT INTO TaskTicket VALUES(113, 'Make new key','Clockwork Toys','2022-02-18','2022-02- 28',5.00,30.00,884,'Leo'); INSERT INTO TaskTicket VALUES(114, 'Re-feather','Taxidermy','2022-04-28',NULL, NULL,NULL,937,'Pilchard'); INSERT INTO TaskTicket VALUES(115, 'Re-attach foot','Clockwork Toys','2022-03-20','2022-03- 22', 5.00, 20.00,867,'Anish'); INSERT INTO TaskTicket VALUES(116, 'Repaint','Painting - small scale','2022-03-23','2022-03-
  • 21. 29',25.00,25.00,867,'Anish'); INSERT INTO TaskTicket VALUES(117, 'Construct replacement for damaged boiler plates','Metal Fabrication','2022-04-22',NULL,NULL,NULL,239,'Benjamin'); INSERT INTO TaskTicket VALUES(118, 'Weld new boiler plates','Welding','2022-04-28',NULL,NULL,NULL,239,'Benjamin'); INSERT INTO TaskTicket VALUES(119, 'Paint boiler','Painting - large scale','2022-04-30',NULL,NULL,NULL,239,'Anish'); INSERT INTO TaskTicket VALUES(120, 'Replace missing chairs','Woodworking','2022-01-05','2022-01-13', 250.00,240.00 ,845,'Benjamin'); INSERT INTO TaskTicket VALUES(121, 'Re-upholster all chairs in vintage fabrics','Fabric restoration','2022-01-15','2022-01-30', 400.00,340.00,845,'Wendy'); INSERT INTO TaskTicket VALUES(122, 'Attach chairs replacing chains as required','Metal Fabrication','2022-01-31','2022-02-10', 180.00,100.00,845,'Spud'); INSERT INTO TaskTicket VALUES(123, 'Rechrome','Painting - small scale','2022-02-28','2022-03- 12', 40.00,40.00,224,'Anish'); INSERT INTO TaskTicket VALUES(124, 'Rebalance scale','Clockwork Toys','2022-03-22','2022- 03-29', 3.00, 20.00,163,'Anish'); INSERT INTO TaskTicket VALUES(125, 'Replace missing cross-rod','Metal Fabrication','2022-03-26','2022-03-30', 30.00, 35.00,246,'Spud'); INSERT INTO TaskTicket VALUES(126, 'Retread','Tractors','2022-01-03','2022-01- 18',340.00,120.00 ,934,'Saffron'); INSERT INTO TaskTicket VALUES(127, 'Refurbish engine','Tractors','2022-01-08','2022-01- 26',430.00, 550.00,934,'Saffron'); INSERT INTO TaskTicket VALUES(128, 'Align finger bars','Metal Fabrication','2022-03-19','2022-
  • 22. 03-21', 0.00, 23.00,468,'JJ'); INSERT INTO TaskTicket VALUES(129, 'Replace plough blade','Metal Fabrication','2022-03-25','2022-03-28',70.00, 35.00,835,'Saffron'); INSERT INTO TaskTicket VALUES(130, 'Repaint with matching original colours','Painting - large scale','2022-03-29','2022-04-15', 105.00, 95.00,835,'Anish'); INSERT INTO TaskTicket VALUES(131, 'Replace corn holder using Oak','Woodworking','2022-01-20','2022-01-29', 80.00, 100.00,348,'Benjamin'); INSERT INTO TaskTicket VALUES(132, 'Trim sharpening wheel','Metal Fabrication','2022-03-16',NULL, NULL,NULL,783,'Spud'); INSERT INTO TaskTicket VALUES(133, 'Re-varnish','Painting - small scale','2022-03-25',NULL, NULL,NULL,783,'Anish' ); INSERT INTO TaskTicket VALUES(134, 'Fit new hands','Metal Fabrication','2022-03-16','2022-03- 22',30.00, 40.00,359,'JJ' ); /* Data input ends */ Resto schema description Resto is a database package that holds the data records for Walton Restorations. For this scenario we are interested in the data that the resto database handles about items for restoration, the tasks needed to complete the restoration, the experts who perform the restoration, and the specialisms needed to complete the tasks. In particular, we are interested in which restoration item requires which tasks, which task is worked on by which experts, which tasks need what specialisms and which expert has expertise in which specialism. Each restoration item must require one or more tasks. Each task must be required by at most one restoration item. Each task may be worked on by at most one expert (this allows a task to be created where an expert has not yet been allocated to work on it). Each expert may work on one or more tasks. Each task must need at most one specialism. Each specialism may be needed on one or more tasks. Each expert must have expertise in one or more specialisms. Each specialism may be the expertise of one or more experts. The information held about restoration items is a unique item code, a description of the item and a description of the work required, along with the insurance value of the item, an estimate for the cost of the work, and the date the item was accepted by Walton Restorations. When work is completed and the item returned there will also be a value for the price charged for the work, and the date It was returned to the client. Walton Restorations do
  • 23. not accept items with an insurance value of greater than one million pounds.Experts have a name, address and email held. (Names are assumed to be unique). Walton Resto also holds some publicity text, if the expert wants to supply some. Walton resto has a record of permission (or not) being given to include the expert's details in the online catalogue, and the date when the permission was given. A list of specialisms is held. And each expert is associated with any of these that they have expertise in. For each specialism held, the expert has a particular charge rate and may hold qualifications related to that expertise. A task (also known as a task ticket) is identified in the resto database using a unique task number issued when it is created. Task information includes a description of the task, and the day the task was created. When a task is complete, the task-ticket is updated by adding the cost of the parts used, the cost of the expert labour used, and the date it was completed. If a task is incomplete then these will be NULL. The domain and datatype descriptions of the attributes in resto are shown in Figure 8. Note this is a simplified scenario as we aren't including details of the Clients, Manager or Parts Used related to restoration process. (Note this description is also given in the resto_schema document).Resto Entity Relationship diagramFigure 7 An entity relationship diagram showing Restorationltem, TaskTicket, Expert and Specialism entity types and the relationship types Requires, WorkedOnBy, HasExpertiseln and Needs. (Note this figure is also given in the resto_schema document).Figure 8 A schema and description of the tables defined in the resto.txt file (note this is also given in the resto_schema document).. Figure 8 This shows a physical schema model consisting of five relations: Restorationltem, TaskTicket, Expert, Specialism and HasExpertiseln. There is an unlabelled line between Restorationitem and TaskTicket, TaskTicket and Expert, TaskTicket and Specialism and Specialism and HasExpertiseln and Expert and HasExpertiseln. There is also a 'note' box labelled Domain definitions.The note box labelled 'Domain definitions' contains domain descriptions for eleven domains: ItemCodes: INTEGER CHECK (VALUE>0), DescriptionString: VARCHAR(120), TaskNumbers: INTEGER CHECK (VALUE)>0), NameString: VARCHAR(120), AddressString: VARCHAR(400), Publicitystring: VARCHAR(120), EmailString: VARCHAR(100) CHECK (VALUE LIKE %@%'), YN: CHECK (VALUE IN ('Y','N;')), SpecialismString: VARCHAR (300), QualificationString: VARCHAR(300) and MonetaryValues: NUMERIC (9,2) CHECK (VALUE>=0.00) The Restorationltem has eight attributes and three constraints. The attributes are ItemCode: ItemCodes , ItemDescription: Descriptionstring , WorkDescription: DescriptionString , InsuranceValue: MonetaryValues, CostEstimate: Montearyvalue , DateAccepted: DATE , DateReturned: DATE and PriceCharged: MonetaryValues. The three constraints state: Requires mandatory: all values of ItemCode must appear in the TaskTicket relation foreign key attribute (ItemCode) representing Requires. 1: DateAccepted must be today or earlier, 2: DateAccepted must be before Date Returned and 3 : InsuranceValue must be below 1 Million. The TaskTicket has nine attributes, three foreign keys and two constraints. The attributes are TaskNumber: TaskNumbers , Description: DescriptionString , SpecialismNeeded: SpecialismString, DateCreated: DATE , DateCompleted: DATE, CostOfParts: MonetaryValues, CostOfLabour: MonetaryValues, ItemCode: ItemCodes and Name: NameString. The foreign keys are: Name(Requires) ItemCode References Restorationltem , Name(WorkedOnBy) Name References Expert and Name(Needs) SpecialismNeeded References SpecialismName(Needs) SpecialismNeeded References Specialism < not null>. The two constraints are: 1 : DateCreated
  • 24. must be today or earlier and 2: DateCreated must be before DateCompleted. The Expert has six attributes and two constraints. The attributes are Name: NameString , Address: AddressString , PublicityText; PublicityString, Email: EmailString , UselnExternal Catalogue: YN and DateApprovedUse: DATE . The constraints are HasExpertiseln mandatory: all values of name must appear in the HasExpertiseln relation foreign key attribute (ExpertName). and 1: Date ApprovedUse must be today or earlier. The Specialism has one attribute. The attribute is Name: SpecialismString . The HasExpertiseln has four attributes, two foreign keys and one note. The attributes are: Expertname: NameString < primary key>, SpecialismName: SpecialismString , ChargeRate: MonetaryValues and QualificationsHeld: QualificationsString. The foreign keys are: Name(HasExpertiseln) ExpertName References Expert and Name(HasExpertiseln) SpecialismName References Specialism. The Note is: 1 . ChargeRate is per hour. a. Write SQL statements that answer each of the requests for data in the resto.txt tables: i. Produce a list of the expert names, rename the output column as experts. (3 marks)ii. Produce a list of the item codes and date accepted, for any restoration item that has not yet been returned. (4 marks) iii. How many task tickets have been created where the specialism needed is 'Tractors'? (3 marks) iv. How many restoration items have been returned? (3 marks) v. List the item code and date accepted for all restoration items that have been accepted between 2022-03-31 and 2022-05-01, but not yet returned (3 marks) vi. List the task number, specialism needed and item code for all task tickets where the description includes mention of 'replace'. (3 marks) vii. For each expert and their specialisms, list the expert's name, email, the specialism and their charge-rate for that specialism. Sort the output by specialism and then by charge-rate (descending order in each case). (3 marks)ii. Produce a list of the item codes and date accepted, for any restoration item that has not yet been returned. (4 marks) iii. How many task tickets have been created where the specialism needed is 'Tractors'? (3 marks) iv. How many restoration items have been returned? (3 marks) v. List the item code and date accepted for all restoration items that have been accepted between 2022-03-31 and 2022-05-01, but not yet returned (3 marks) vi. List the task number, specialism needed and item code for all task tickets where the description includes mention of 'replace'. (3 marks) vii. For each expert and their specialisms, list the expert's name, email, the specialism and their charge-rate for that specialism. Sort the output by specialism and then by charge-rate (descending order in each case). (3 marks)viii. For each expert and their specialisms, if they have given permission for their details to appear in the catalogue, list the expert's name, email, the specialism and their charge-rate for that specialism. Sort the output by specialism and then by charge-rate (descending order in each case). (2 marks) ix. For each restoration item that has an insurance value of over 300.00, and has a task ticket that was worked on by an expert called 'Benjamin', give the item code, item description, and insurance value. The list should be in order of item code. (4 marks) x. List any expert that has not worked on any tasks. (3 marks) xi. For each task ticket that has been completed, list the task number, item code and the combined cost of parts and labour, for that task, under the heading costs. Show the list in order of the item code values. (4 marks) xii. For each restoration item, list the item code and the number of task tickets created for that item. (4 marks)xiii. For each restoration item that has been returned, list the item code and the sum of the total cost of parts and labour for all task tickets related to that item code. Give the sum of costs column the heading total_cost and display the result in ascending order of
  • 25. this column. (5 marks) (44 marks) b. What request does the following SQL answer? (Note that a request should be an English language question or description like the ones in part a), not an account of how the data is processed to produce the result.) SELECT Name, COUNT (SpecialismName) FROM Expert JOIN HasExpertiseIn ON Name = ExpertN: WHERE UseInExternalCatalogue = ' Y ' GROUP BY Name HAVING COUNT (SpecialismName) > 2; (5 marks) c. Describe, using the logical processing model, the evaluation of the following query: SELECT Name, COUNT(*) FROM TaskTicket WHERE DateCompleted IS NULL GROUP BY Name HAVING COUNT ()>1;d. Consider the information: The work described by task ticket 117 has been completed by Benjamin on 2022-04-26. Benjamin's labour was 88.00 and they used 110.00 in parts. Add this information to the task ticket table using an SQL UPDATE statement, then write a query to show that your update was successful. NOTE: after you successfully run this UPDATE it will change some of the results you achieve with the queries you wrote in part a). If you have not yet produced the output data for your TMA submission document, you will need to re-run resto.txt in order to reset the content of the database. ( 3 marks) e. Describe the effect of the LEFT OUTER JOIN in SQL when used to join the Specialism and HasExpertiseIn tables on the Name = SpecialismName attribute comparison. SELECT Name, ExpertName FROM Specialism LEFT OUTER JOIN HasExpertiseIn ON Name = SpecialismName ORDER BY Name; What request would that LEFT OUTER JOIN satisfy? (5 marks)f. Walton Restorations wants to produce the data for their online catalogue. You are to create an SQL VIEW with the name 'Catalogue'. The view should produce rows showing each expert's name, email address, specialism, charge-rate and qualifications they hold. The view should have columns named Name, ContactEmail, Specialism, HourlyRate and RelevantQualification. Only data where the expert has given permission to be included in the catalogue should appear in the data defined by the VIEW. Write a query showing the data your VIEW defines. Your solution document should contain the CREATE VIEW statement, the query and the output of the query. (5 marks) HAVE YOU INCLUDED YOUR SQL AND OUTPUT IN YOUR SOLUTION DOCUMENT? For this question, in your solution document you MUST include your SQL statements and a copy of the output produced by the evaluation of each of your statements. If you were unable to produce a working query then a copy of any error messages should be included in your solution. A text copy-and-paste of the SQL statements and output should be used. Please do not use screenshots for your SQL statement and output, as they are difficult to annotate for feedback and marking. If you do not include both SQL statement and output (or error messages) then your tutor will not mark your answer for that part of the question.