forked from aayushi-2003/DreamHouse-DBMS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtableCreation.sql
100 lines (88 loc) · 2.33 KB
/
tableCreation.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
create schema DreamHome;
use DreamHome;
CREATE TABLE staff(
staff_number char(5),
staff_name varchar(30),
Sex char(1),
DOB date,
Salary numeric,
Branch_Number char(5) references branch(branch_number),
Position varchar(30),
PRIMARY KEY (staff_number)
);
CREATE TABLE Manager (
staff_number char(5) REFERENCES STAFF(STAFF_NUMBER),
Manager_Start_Date date,
Manager_Bonus numeric
);
-- CREATE TABLE Supervisor (
-- staff_number char(5) REFERENCES STAFF(STAFF_NUMBER)
-- );
CREATE TABLE Assistant (
staff_number char(5) REFERENCES STAFF(STAFF_NUMBER),
Supervisor_Number char(5) references staff(staff_number)
);
CREATE TABLE Branch (
Branch_Number char(5),
BStreet varchar(30),
BCity varchar(30),
BPincode char(6),
BPhone_Number numeric(10),
PRIMARY KEY (Branch_Number)
);
CREATE TABLE Owner(
Owner_Number char(5),
Personal_or_Business_name varchar(30),
Is_Business char(1),
OAddress varchar(50),
OCity varchar(30),
OPincode char(6),
Telephone_Number numeric(10),
PRIMARY KEY (Owner_Number)
);
-- CREATE TABLE Business{
-- Owner_Number CHAR(5) REFERENCES OWNER(OWNER_NUMBER),
-- Business_Type varchar(15),
-- Contact_Name ???
-- };
CREATE TABLE Property(
Property_Number char(5),
Type varchar(15),
Rooms int,
Rent numeric,
PStreet varchar(30),
PCity varchar(30),
PPincode char(6),
Managed_By char(5) references staff(staff_number),
Owner_Num char(5) references owner(owner_number),
Registered_At_Branch char(5) references branch(branch_number),
Is_Rented char,
Last_Rented_Out date,
PRIMARY KEY (Property_Number)
);
CREATE TABLE Client (
Client_Number char(5),
Full_Name varchar(30),
Branch_Number char(5) references branch(branch_number),
Registered_By_Staff char(5) references staff(staff_number),
Date_Registered date,
PType varchar(15),
Max_PRent numeric,
PRIMARY KEY (Client_Number)
);
CREATE TABLE Lease (
Lease_Number char(8),
Client_Number char(5) references client(client_number),
Property_Number char(5) references property(property_number),
Payment_method varchar(30),
Deposit_Paid char,
Rent_Start date,
Rent_Finish date,
PRIMARY KEY (Lease_Number)
);
CREATE TABLE Property_Report (
Property_Number char(5) references property(property_number),
Client_Number char(5)references client(client_number),
Comment_Date date,
Comment varchar(80)
);