You are on page 1of 10

Table Creation Commands:

Table 1:
Customer table:
Creation:
Create table Customer(customerno int not null primary
key,csurname varchar(25) not null,cforenames varchar(25)
not null,cstreet varchar(25) not null,carea varchar(20),ctown
varchar(20) not null,cpostcode varchar(8) not null,ctelno
varchar(12),clicenceno varchar(16) not null,cmaxrentalpd
int);

Insertion:
insert into Customer values (201, 'Black', 'David', '27
Breckon Drive', 'Leachmere', 'Sunderland', 'SR5 9TR',
'01916744567', 'BLACK671234DE8NB', 20);
insert into Customer values (202, 'Stephenson', 'Arthur',
'12 Davis Street', 'Heaton', 'Newcastle', 'NE1 8TY',
'01912324564', 'STEPH783421AW9DS', 15);
insert into Customer values (203, 'Lewis', 'Emma', '13 Hope
Street', 'Denton', 'Newcastle', 'NE4 7GH','01913452332',
'LEWIS563567EJ9YT', 17);
insert into Customer values (204, 'Alexander', 'Jessica', '51
High Street', NULL, 'Whitley Bay', 'NE26
5TR','01912534545', 'ALEXA66567JY8TY', 18);
insert into Customer values (205, 'Doyle', 'David', '78
Larbert Drive', 'Roker', 'Sunderland', 'SR6
OFG','01915156789', 'DOYLE72878DH978', 17);
insert into customer values (206, 'Griffen', 'James', '22 Nile
Street', NULL, 'Penshaw', 'SR7 8SD','01914567834',
'GRIFF77456JH878', 16);
insert into customer values (207, 'Payne', 'Helen',' 32
Sunny Drive', 'Redhouse', 'Sunderland', 'SR4
5WR','01914678762', 'PAYNE78673HG786', 20);
insert into customer values (208, 'Saunders', 'William', '5
Brook Drive', NULL, 'Penshaw', 'SR7 3TS','01914563478',
'SAUND67784WR876', 50);

Table 2:
Staff table:
Creation:
create table staff(staffno int not null primary key,branchno int
not null,ssurname varchar(25) not null,sforenames
varchar(25) not null,sstreet varchar(25) not null,sarea
varchar(20),stown varchar(20) not null,spostcode varchar(8)
not null,stelno varchar(12),sgender char(1),ssalary int);
Insertion:
insert into staff values (101, 11, 'Downey', 'Carol', '21
Regent Terrace', 'Grangetown', 'Sunderland','SR2 9YR',
'01915670976', 'F', 23000);
insert into staff values (102, 11, 'Smith', 'James', '11 Mill
Lane', 'Fulwell', 'Sunderland', 'SR6 8EW','01915489867',
'M', 19000);
insert into staff values (103, 12, 'Harvey', 'David', '19
Burnhope Way', NULL, 'Peterlee', 'SR8
2GH','01915865543', 'M', 28000);
insert into staff values (104, 12, 'Marshall', 'June', '35 York
Road', NULL, 'Hartlepool', 'TS26 9SD','01429274245', 'F',
18000);
insert into staff values (105, 13, 'James', 'Veronica', '23
Victoria Square', 'Jesmond', 'Newcastle','NE2 3RE',
'01912816856', 'F', 29000);
insert into staff values (106, 13, 'Tully', 'Peter', '12 Osborne
Road', NULL, 'Newcastle', 'NE2 2CB','01912122300', 'M',
24000);
insert into staff values (107, 14, 'Times', 'lan', '32 Leazes
Crescent', NULL, 'Hexham', 'NE46 7YT','01434601976', 'M',
32000);
Table 3:
Branch table:
Creation:
create table branch(Branchno int not null primary key,bstreet
varchar(25) not null, barea varchar(20),btown varchar(20)
not null,bpostcode varchar(8) not null,btelno varchar(12));

Insertion:
insert into branch values (11, '56 High Street', 'Fulwell',
'Sunderland', 'SR4 8UT', '01915143432');
insert into branch values (12, '32 Wessington Lane', NULL,
'Peterlee', 'SR8 2NY', '01915180292');
insert into branch values (13, '23 Peters Street', 'Heaton',
'Newcastle', 'NE1 9TR', '01912328345');
insert into branch values (14, '11 Wright Way', NULL,
'Hexham', 'NE47 5RT', '01434684325');

Table 4:
Vehicle rent table:
Creation:
create table vehrent(vehicleno int not null primary
key,vehReg varchar(8) not null,vehmake varchar(12) not
null,vehmodel varchar(12) not null,vehcc varchar(8) not
null,vehgeartype varchar(10) not null,vehcolour varchar(12)
not null,vehseats integer not null,vehrentpd int not
null,vehinspd int,staffno int not null references
staff(staffno),branchno int not null references
Branch(branchno),available varchar(1),rcomments
varchar(150));

Insertion:

insert into vehrent values (1001, 'S51 NGH', 'Ford',


'Mondeo', '2000', 'M', 'Red', 4, 23, 9, 101, 11, 'Y', NULL);
insert into vehrent values (1002, 'T76 HGH', 'Ford', 'Fiesta',
'1600', 'M', 'Blue', 4, 16, 7, 102, 11, NULL, NULL);
insert into vehrent values (1003, 'R78 RTD', 'BMW', '5-
Series', '2500', 'A', 'Silver', 5, 37, 17, 101, 11, 'Y', NULL);
insert into vehrent values (1004, '556 TSG', 'Fiat', 'Brava',
'1600', 'M', 'Brown', 4, 19, 9, 102, 11, NULL, NULL);
insert into vehrent values (1005, 'W67 YTD', 'Nissan',
'Primera', '2000', 'A', 'Silver', 4, 22, 12, 103, 12, 'Y', NULL);
insert into vehrent values (1006, 'W72 YTD', 'Nissan',
'Almera', '1400', 'M', 'Blue', 4, 16, 6, 103, 12, NULL, NULL);
insert into vehrent values (1007, 'S67 YFG', 'Peugeot', '406',
'1800', 'M', 'Yellow', 4, 21, 12, 104, 12, NULL, NULL);
insert into vehrent values (1008, 'T89 HJK', 'Proton',
'Persona', '1500', 'M', 'Black', 4, 16, 6, 104, 12, 'Y', NULL);
Insert into vehrent values (1009, 'S45 KLR', 'Mazda', 'Xedos
9', 2300, 'A', 'Grey', 4, 34, 15, 105, 13, 'Y', NULL);
insert into vehrent values (1010, 'T23 TRD',
'MercedesBenz', 'SLK', '2300', 'A', 'Silver', 2, 30, 14, 105,
13,NULL, NULL);
insert into vehrent values (1011, 'W56 YFG', 'Audi', 'RS4',
'2550', 'M', 'Red', 4, 25, 12, 106, 13, NULL, NULL);
insert into vehrent values (1012, 'S45 HTR', 'Seat', 'Leon',
'1600', 'M', 'Yellow', 4, 16, 8, 106, 13, 'Y', NULL);
insert into vehrent values (1013, 'T34 URT', 'Skoda',
'Felicia', '1900', 'M', 'Red', 4, 15, 9, 106, 13, NULL, NULL);
insert into vehrent Values (1014, 'W45 WDF', 'Lexus',
'IS200', '2000', 'A', 'Silver', 4, 25, 11, 107, 14, NULL, NULL);
insert into vehrent values (1015, 'S42 TJP', 'Porsche',
'Boxster', '2700', 'M', 'White', 2, 38, 19, 107,14,'Y', NULL);

Table 5:
Vehicle Rental Agreement table:
Creation:
create table RentalAgreement(AgreeNo int not null primary
key,vehicleno int not null references
vehrent(vehicleno),customerno int not null references
customer(customerno),rentpd int,paymethod varchar(10) not
null,depamount int,deppaid varchar(10),startdt date not
null,enddate date);

Insertion:
insert into rentalagreement values (2001, 1002, 203, 16, 'P',
50, 'Y', '12-Mar-2002', '17-Mar-2002');
insert into rentalagreement values (2002, 1007, 208, 21, 'C',
20, 'Y', '15-Mar-2002', '16-Mar-2002');
Insert into rentalagreement values (2003, 1001, 205, 19,
'A', 0, 'N', '15-Mar-2002', '14-Apr-2002');
Insert Into rentalagreement values (2004, 1006, 202, 16, 'P',
20, 'Y', '19-Mar-2002', '25-Mar-2002');
Insert into rentalagreement values (2005, 1008, 203, 16, 'C',
25, 'Y', '25-Mar-2002', '26-Mar-2002');
Insert into rentalagreement values (2006, 1002, 207, 15,
'A', 0, 'N', '26-Mar-2002', '30-Apr-2002');
insert into rentalagreement values (2007, 1010, 206, 25, 'P',
50, 'Y', '28-Mar-2002', '30-Mar-2002');
insert into rentalagreement values (2008, 1005, 203, 22, 'P',
20, 'Y', '01-Apr-2002','08-Apr-2002');
insert into rentalagreement values (2009, 1015, 204, 38, 'C',
20, 'Y', '02-Apr-2002', '04-Apr-2002');
insert into rentalagreement values (2010, 1002, 201, 16, 'P',
0, 'N', '06-Apr-2002', '10-Apr-2002');
insert into rentalagreement values (2011, 1002, 201, 16, 'P',
0, 'N', '12-Apr-2002', '15-Apr-2002');
insert into rentalagreement values (2012, 1003, 204, 37, 'P',
50, 'Y', '12-Apr-2002', '14-Apr-2002');
insert into rentalagreement values (2013, 1005, 203, 22, 'P',
20, 'Y', '15-Apr-2002', '20-Apr-2002');
insert into rentalagreement values (2014, 1007, 202, 21, 'C',
20, 'Y', '18-Apr-2002', '25-Apr-2002');
insert into rentalagreement values (2015, 1002, 205, 16, 'P',
20, 'Y', '20-Apr-2002', '22-Apr-2002');

Table 6:
Test Drive:
Creation:
create table TestDrive(Vehicleno int not null,customerno int
not null references customer(customerno),testdate
date,dcomments varchar(50),primary
key(vehicleno,customerno));

Insertion:
insert into testdrive values (1003, 205, '14-Mar-2002', 'Nice
car but far too expensive');
insert into testdrive values (1001, 205, '15-Mar-2002',
'Good performance');
insert into testdrive values (1004, 201, '17-Mar-2002', 'Not
enough leg room in the back');
insert into testdrive values (1014, 203, '21-Mar-2002', 'Nice
car, shame about the price');
insert into testdrive values (1011, 204, '01-Apr-2002', 'Do
not like the colour');
insert into testdrive values (1002, 206, '02-Apr-2002', 'Car
too small');

Table 7:
Vehicle Service:
Creation:
create table vehservice(vehicleno int not null references
vehrent(vehicleno),staffno int not null references
staff(staffno),servicedate date not null,scomments
varchar(150),primary key(vehicleno,staffno,servicedate));

Insertion:
insert into vehservice values (1007, 104, '17-Mar-2002',
'Routine service');
insert into vehservice values (1002, 102, '18-Mar-2002',
'Check clutch and brake fluid');
insert into vehservice values (1010, 105, '22-Mar-2002',
'Some paintwork scratches to be removed from previous
hire');
insert into vehservice values (1006, 103,'27-Mar-2002',
'Major service - check washers');
insert into vehservice values (1012, 106, '01-Apr-2002',
'Routine maintenance');

You might also like