Perbaikan Table

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

CREATE TABLE PropertyForRent (

propertyNo CHAR(4) NOT NULL,


street VARCHAR(25) NOT NULL,
city VARCHAR(20) NOT NULL,
postcode CHAR(7) NOT NULL,
pType VARCHAR(18) NOT NULL,
rooms NUMBER(5),
rent SMALLINT,
ownerNo CHAR(4) NOT NULL,
staffNo CHAR(4),
branchNo CHAR(4) NOT NULL,
PRIMARY KEY (propertyNo),
FOREIGN KEY (ownerNo)
REFERENCES PrivateOwner (ownerNo),
FOREIGN KEY (staffNo)
REFERENCES Staff (staffNo),
FOREIGN KEY (branchNo)
REFERENCES Branch (branchNo)
);

CREATE TABLE CClient (


clientNo CHAR(4) NOT NULL,
fName VARCHAR(50) NOT NULL,
lName VARCHAR(50) NOT NULL,
telNo CHAR(14) NOT NULL,
prefType VARCHAR(18) NOT NULL,
maxRent NUMBER(5),
eMail VARCHAR(50) NOT NULL,
PRIMARY KEY (clientNo)
);

CREATE TABLE Viewing (


clientNo CHAR(4) NOT NULL,
propertyNo CHAR(4) NOT NULL,
viewDate VARCHAR(10),
vComment VARCHAR(20),
PRIMARY KEY (clientNo , propertyNo , viewDate),
FOREIGN KEY (clientNo)
REFERENCES CClient (clientNo),
FOREIGN KEY (propertyNo)
REFERENCES PropertyforRent (propertyNo)
);

CREATE TABLE Registration (


clientNo CHAR(4) NOT NULL,
branchNo CHAR(4),
staffNo CHAR(4) ,
dateJoined DATE NOT NULL,
PRIMARY KEY (clientNo),
FOREIGN KEY (clientNo)
REFERENCES CClient (clientNo),
FOREIGN KEY (branchNo)
REFERENCES Branch (branchNo),
FOREIGN KEY (staffNo)
REFERENCES Staff (staffNo)
);

CREATE TABLE Branch (


branchNo CHAR(4) NOT NULL,
street VARCHAR(25) NOT NULL,
city VARCHAR(20) NOT NULL,
postcode CHAR(7) NOT NULL,
PRIMARY KEY (branchNo)
);

CREATE TABLE Staff (


staffNo CHAR(4) NOT NULL,
fName VARCHAR(50) NOT NULL,
lName VARCHAR(50) NOT NULL,
sPosition VARCHAR(15) NOT NULL,
sex CHAR(1),
DOB DATE,
salary INT,
branchNo CHAR(4) NOT NULL,
PRIMARY KEY (staffNo),
FOREIGN KEY (branchNo)
REFERENCES Branch (branchNo)
);

CREATE TABLE PrivateOwner (


ownerNo CHAR(4) NOT NULL,
fName VARCHAR(50) NOT NULL,
lName VARCHAR(50) NOT NULL,
street VARCHAR(25) NOT NULL,
city VARCHAR(20) NOT NULL,
postcode CHAR(7) NOT NULL,
telNo CHAR(14) NOT NULL,
eMail VARCHAR(50) NOT NULL,
PRIMARY KEY (ownerNo)
);

You might also like