Database Assignment-Ll Dream Home Database System Nasar Ahmad BSCM-F19-415
Database Assignment-Ll Dream Home Database System Nasar Ahmad BSCM-F19-415
Database Assignment-Ll Dream Home Database System Nasar Ahmad BSCM-F19-415
Database Diagram:
Database Code:
-- *************************************
-- Lab 7
--1 Dream Home Database Creation
--2 Create Tables
--3 Create Relationships
--4 Insert Data
-- Solutions
--1
CREATE DATABASE DREAMHOMEE;
--2
CREATE TABLE Branch
(
branchNo nchar(20) primary key,
street nchar(100) not null,
city nchar(50) not null,
postcode nchar(50) not null
);
--data insertion in branch table
insert into Branch(branchNo,street,city,postcode)
values
('B005','22 Deer Rd','London','SW1 4EH'),
('B007','16 Argyll St','Aberdeen','AB2 3SU'),
('B003','163 Main St','Glasgow','G11 9QX'),
('B004','32 Manse Rd','Bristol','BS99 1NZ '),
('B002','56 Clover Dr','London','NW10 6EU');
-- Staff Table Creation
CREATE TABLE Staff
(
staffNo nchar(20) primary key,
fName nchar(100) not null,
lName nchar(100) not null,
position nchar(50) not null,
sex nchar(20) not null,
DOB date not null,
salary money null,
branchNo nchar(20),
constraint fk_staff_branch foreign key(branchNo)
references Branch(branchNo)
);
--insertion in staff table
insert into Staff(staffNo,fName,lName,position,sex,DOB,salary,branchNo)
values
('SL21','Jhon','White','Manager','M','1-Oct-45',30000,'B005'),
('SG37','Ann','Beech','Assistant','F','10-Nov-60',12000,'B003'),
('SG14','David','Ford','Supervisor','M','24-Mar-58',18000,'B003'),
('SA9','Mary','Howe','Assistant','F','19-Feb-70',9000,'B007'),
('SG5','Susan','Brand','Manager','F','3-Jun-40',24000,'B003'),
('SL41','Julie','Lee','Assistant','F','13-Jun-65',9000,'B005');
-- Client Table
CREATE TABLE Client
(
clientNo nchar(20) primary key,
fName nchar(100) not null,
lName nchar(100) not null,
telNo nchar(50) not null,
prefType nchar(20) not null,
maxRent int not null
);
--insertion in client
insert into Client(clientNo,fName,lName,telNo,prefType,maxRent)
values
('CR76','Jhon','Kay','0207-774-5632','Flat','425'),
('CR56','Aline','Stewart','0141-848-1825','Flat','350'),
('CR74','Mike','Ritchie','01475-392178','House','750'),
('CR62','Mary','Tregear','01224-196720','Flat','600');
-- Owner Table
CREATE TABLE PrivateOwner
(
ownerNo nchar(20) primary key,
fName nchar(100) not null,
lName nchar(100) not null,
adress nchar(200) not null,
telNo nchar(50) not null,
);
--insertion in PrivateOwner
insert into PrivateOwner(ownerNo,fName,lName,adress,telNo)
values
('CO46','Joe','Keogh','2 Fregus Dr,Aberdeen AB2 7SX','01224-891212'),
('CO87','Carol','Farrel','6 Achray St,Glasgow G32 9DX','0141-357-7419'),
('CO40','Tina','Murphy','63 Well St,Glasgow G42','0141-943-1728'),
('CO93','Tony','Shaw','12 Park Pl,Glasgow G4 0QR','0141-225-7025');
-- Registration Table