der the relational schema for Part of the dreamhome case study
© saints:
"Create a database with name “DreamHeme” and now create all the tables sted above with const
+ Sranch(branchno streetcty postcode)
Create table b
varchar(8)};
stcode
"ch(branchno char) primary key stret varchar(20) not nul city varcha(20) not nl PO!
utp
Table created,
2.statt St2tfno,fname,tame,position sex,008,salarybranchno)
‘“reate table staffistatino varchar(7) primary key,{name varchar(10) not null,Iname varchar(10)
ot nullpostion varchar(20) not nulsex char,008 date salary decimal(7,4) not null,branchno char(
4) not null foreign key(branchno) references branch{branchno));
Output:
Table created.
3-Porpertyforrent(propertyno street, city,postcode,type,rooms,rent,
Greate table propertyforrent(propertyno char{) primary key,stret varchar(20) not null city varchar(15) not nll,
OS" 20de varchar(6) not null, type varchar(8) not null,rooms smallint not null, rent decimal(9,3) not null,ownerno.
varchar(7) not null, staffno: ‘varchar(5) foreign key(staffno) references staff (staffno),branchno char(4) not null);
ownerno,staffno.branchno)
Output:
Table created.
4.Client(ctientno,fname,Iname,telino,preftype,maxrent email)
create table client(clientno char(4) primary key fname varchar(10) not null,iname varchar(10) not null, telino
varchar(20) not null,preftype varchar(8) not null maxrent decimal(6,1),email varchar(25) not null;
null);
Output:
Table created.
5.Privateowner(owerno fname,name,address,tellno,emall, password)
create table privateowner(ownerno char(4) primary key, fname varchar(8) not nullname varchar(10) not
null,address varchar(30) not nulltelino varchar(15) not null, email varchar(25) not nul passsword varchar(10));
Output:
Table created.
6.Viewing(clientno,propertyno,viewdate,viewcomment)
create table viewing(clientno varchar(6) primary key,propertyno varchar(8) not null,viewdatedate,viewcomment
varchar(20));
Output:
Table created.
Scanned with CamScannersaistration{clientno,branchno,staffno,datejolned)
fate table registration(ctinetno char(4) primary key,branchno varchar(6) not nullstaffno varchar(6) not nul,
‘tejoined date};
Output:
Table created
2,Jinsert a new row into the table supplying data for all columns
2.Biunch(branchno,street,city,postcode)
insert into branch values('8005
22 Deer Rd! "London’ SW1AEH');
1 row created.
insert into branch values ('8007''16 Argyl St‘Aberdeen’’AB2 35U));
1 row created.
insert into branch values('B003''163 Main St, 'Glasgow’,'G11 90%’);
1 row created.
inert into branch values('8004"/'32 Manse Rai,’Bristol,'3S99 1NZ’);
1 row created.
insert into branch values('8002','6 Clover Dr'London’,'NW 10 6EU');
row created,
select * from bran
BRANCHNO STREET cay POSTCODE
B005 22 Deer Rd London’ ‘Swi 4EH
8007 16 Areyilst Aberdeen ‘AB2 3SU
003 163 Main St Glasgow G11 90x
Boos 32 Manse Rd Bristol 18599 1NZ
002 56 Clover Dr London NW 10 6U
2.Stafi(staffno,fname,lame position sex,DOB, salary, branchno)
insert into staff values('S121', John',White',’Manager’,'M''1-Oct-45','30000','B005');
Lrow created.
insert into staff values('SG37’,'Ann','Beech','Assistant’ F'10-Nov-60'/'12000,'8003');
1 row created.
insert into staff values('SG14’,'David','Ford' ‘Supervisor
''24-mar-58,'18000",'8003');
1 row created.
insert into staff values('SAS'/Mary' Howe',’Assiatant’ ,'19-Feb-70',9000','8007');
1 row created. :
insert into staff values('SGS" Susan’ 'Brand',’Manager’,F'3-jun-40','24000' 8003);
11 row created.
cert into staff values('SLJulie''Loe' Assistant’ ''13-june-40','9000''8005');
ins
Scanned with CamScannersow created,
select * from staff;
| STAFFNO | FNAME | ~UNAME | Postion” | “s bon SALARY
sia] John [White | ~ Manager| M | O1-0CT-45 30000 |
- ‘Ann | Beech | Assistant | F | a0-NOVv-co |” 12000
S614] David [Ford | Supervisor | 2a-miansa | 18000
SAS Mary | Howe: Assiatant’ | F | 19-FEB-70 ‘9000 8007
$65] Susan | Brand Manager | F | O34UN-40 24000 ‘8003,
Sar Tulle toe ‘sistant | F | 43dUN40 9000 8005
3.Porpertyforrent(propertyno,street city, postcode, type, rooms,rent,ownerno,staffno.branchno)
insert into propertyforrent values('PA14'16 Holhead' ‘Aberdeen',’AB7 5SU’,'House’'6''650,
‘coal
\'SA9! 'B007");
1 row created.
insert into propertyforrent values('PL94’,'6 Argyl St London','Nw2;, Flat, 4','400'/CO87"
1'5L41'/'B005');
t row created.
insert into propertyforrent values('PG4','6 Lawrence St'/Glasgow',’G11 9QX;,'Fat,'3,350'"
c040',"'8003'};
L row created.
175''C093'S637
insert into propertyforrent values('PG36,'2 Manor Rd 'Glasgow',/G32 40X Flat’
"18003";
Lrow created.
insert into propertyforrent values('PG21'/'18 Dale Rai, 'Glasgow’'G12',
"S637,
Lrow created.
50'CO
Novar Dr''Glasgow’,'G12 AX, Flat’
insert into propertyforrent values(/PG1
93'/'SG14'/'B003");
1 row created
Scanned with CamScanner._ lect * from propertyforrent1;
eROPERTYNO | STREET | CITY | POSTCODE | TYPE RENT [ OWNERO | STAFENO | BRANCHNO
PAI4 16 Aberdeen | AB75SU | House | 6 650 C046 SAD 007
Hothead
PLO4 G Argyll | London Nw2 Flat | 4 400, co87 SL41 00S
St
PG4 6 3 350 co40 8003
Lawrence | Glasgow | G1190X | Flat
St
PG36 2Manor | Glasgow | G32 4QX Flat | 3 375 C093 ‘$637 003
Rd
PG21 18Dale | Glasgow G12 House | 5 600 co87 $637 B003
Rd
PG16 SNovar | Glasgow G12 AX Flat | 4 450 C093 SG14 B003
Dr
Grows selected.
4.Client{clientno,fname,Iname,tellno,preftype,maxrent,email)
insert into client values('CR76,John’,'Kay’0207-774-5632,, lat’ '425',
[email protected]');
1 row created.
Insert into client valuest'CRS6,Aline'Stewart’'0141-848-185' lat’ '350','
[email protected]');
1 row created.
insert into client values('CR74','Mike' 'Ritche' '01475-392176,,'House’,'750,'
[email protected]'};
Lrow created.
insert into client values('CR62!,"Mary,Tregear,'01224-196720', Fat','600''
[email protected]’);
L row created,
select * from client;
CLIENT [FNAME] LNAME | TELLNO PREFTYPE | MAXRENT | EMAIL
R76__| John _| Kay | 0207-774-5632 Tat 425 | john.kay@gmailcom
R56 | Aline _| Stewart | 0141-848-1825 | flat 350 |
[email protected]
CR74__| Mike | Ritche | 01475-392176 | House | 750 |
[email protected]
cR62__| Mary _| Tregear_| 01224-196720 Flat 600 __ |
[email protected]
5.Privateowner{ownerno,fname,iname,address,tellno,email,password)
insert into privateownervalues('CO46',Joe,'Keogh’,'2 Ferguus Dr,Aberdeen AB2 7Sx’,01224-
ieeweenens):
861212,
[email protected]’,
row created.
insert into private owner valuest"CO87’,'Carol,'Farrel’,'6 Achray St,Glasgow G32 9AX’,0141-848-
1825,'
[email protected],*****#**');
1 row created.
insert into privateownervalues('CO40’,‘Tina',’Murphy''63 Well St,Glasgow G42', 0141-943-
1728,'
[email protected]’,'********");
row created.
Scanned with CamScannerinsert into privteownervalues('CO93},"Tony’,'shaw’'12 Park Pl,Glasgow G4 OQR’,0141-225-7025,
‘tony
[email protected], *#+¥4940
‘Lrow created.
select * from privateowner;
‘OWNE | FNAME | LNAME “ADDRESS TELINO EMAIL PASSWORD
RNO
Coa6 | Joe | Keogh | 2FerguusDrAderdee | 01224861212 | _
[email protected] coueeaee
1 AB27SX
C087 | “Carol | Farrel | 6 Achrayst,Glasgow | 0141-357-7419 | cfarrel@gmailcom
G3290x
Coao | Tina | Murphy | 63WellSt,Glasow | 0141-943-1728 | tinam@hotmailicom
a2
O83 | Tony | Shaw | 12ParkPllasgow | 0141-2257025 | tonyshaw@arkcom | ****ee*
Ga00R
6.Viewing(clientno,propertyno,viewdate,viewcomment)
insert into viewing values('CR56;PA14''24-May-13'Too small’;
1 row created,
insert into viewing values('Cr76",'PG4’,'20-Apr-13','too remote’);
Lrow created
insert into viewing values('CRS6;,'PG4’,26-May-135'");
Lrow created.
insert into viewing values('CR62',PA14’,'14-May-13','no Dining Room’);
1 row created.
insert into viewing values('CRS6;PG36,'28-Apr-135,");
1 row created.
select * from viewing;
CLENT PROPERTY VIEWDATE VIEWCOMMENT
RSS PAIS 24MAY-13 “Too small
176 PGS 20-APR-13 too remote
RSE PGs 26-MAY-13
R62 PAI EURYINEE] ‘no Dining Room
CRS6 P36 28-APRA3
7.Registration(clientno,branchno,staffno,datejoined)
insert into registration values('CR76;,'B005','SL4:
row created.
insert into registration values('CRS6','B003',
row created.
insert into registration values('CR74','8003''SG37\"16-Nov-11);
Scanned with CamScannerA row created,
tnsert into registration values('CR62''8007'SA9',7-Mar-12'),
1 row created,
select * from registration;
CLINENTNO. BRANCHNO _[STAFFNO | _DATEJOINED
CR76 O05 Sud O2-JAN-13
RSG 003 ‘G37 LLAPR-12
R74 003 ‘5637 16-NOV-11
CREZ 8007 SA. (O7-MAR-12
23. update Staff set fName="Dravid' where staffNo='SL21";
Select * from Staff;
Output:
STAFENO FNAME” LNA!
siz Dravid White
037 Ann Beech
son Dead For
May Howe
‘Susan Brand
ie bse
POSITION
Manager
‘sistant
‘Assistant
u
&
Supenisor
F
F
F
Manager
4, Delete from Staff where staffNo='SL41';
Select * from Staff;
STAFFNO
sit David White
sc37 Ann Beech
sore David = Ford
Mary Howe
Susan
FNAME _LNAME
POSITION
S.alter table Branch add email varchar(20);,
desc Branch;
output:
Table Column _
ppawc BRANCHN
u 9
STREET
omy
POSTCODE
EMAIL
Data
Type
‘Number
Varchar2
Varehar2
Number
Varchar2
Lengt
2
20
SEX
sex” //b08 SALARY
BRANCHNO
01 30000 8005,
foNov.so 12000 003
2aMaR-s8 16000 8008
19FEB-70 9000 007
Precisle | Seal
Primary
Key
SALARY BRANCHNO |
Nultabt
QNVOn 8
Defaut
t
Commen
t
Scanned with CamScanner_/& drop table Branch;
desc Branch;
output:
Object to be described could not be found,
7. truncate table em
select * from emp;
output:
ho data found
8. create index Indext on Staff(fName,|Name);
Output:
Index created.
drop index Index on Staff;
9. select * from Registration;
Output:
{[GLieWTNO” BRANCHNO” STAFFHO DATEVONED
rn a
cre mn sor tans |
cam cov wenover |
neem cao onan
10. select * from Staff;
Output:
waite” POSITION” SEX DOB SALARY BRANCHNO |
FNAME
“bravid White -—=«sManager-=«M~—=«=«OY-0CT-45 20000 BOOS |
Ann Beech Assistant «= F_=S«TONOVSD 12000 BOS
Dovid Ford =—=««Supervisor.«M=—24MARSB 18000 (8003
May Howe = Assitant «=F IOFEB-7O 8000 007
F GaUN40 24000 BOO |
11, select * from Staff where salary>10000;
output
SYAFFNO FNAME LAME” PosiTioN SALARY” BRANCHNO
Soma Wite Manager a
gor km ook Matat waa
‘sGi4 David Ford ‘Supervisor M 18000 003, |
r F 03-JUN-40
Manager
Output:
Scanned with CamScanner_ARoPERTYNO
Poa
Pata
13. select staffNo,{Name,IName,salary from Staff;
output:
STAFFNO FNAME LNAME SALARY
si2t David — Whte 30000 |
so37 An Beech 12000 |
sou David Ford 18000 |
sao May Howe 9000 |
S65 susan Brand 2400
Scanned with CamScanner