-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql.txt
53 lines (47 loc) · 1.14 KB
/
sql.txt
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
CREATE TABLE apartment (
apt_no varchar(50),
apt_type varchar(50),
rent int(50),
occupied varchar(50),
PRIMARY KEY (apt_no)
);
CREATE TABLE management (
mgt_id varchar(50),
mgt_username varchar(50),
mgt_password varchar(50),
PRIMARY KEY (mgt_id)
);
CREATE TABLE tenant (
t_id varchar(50),
t_password varchar(50),
t_name varchar(50),
t_phone varchar(50),
t_national_id varchar(50),
t_lease_length int(50),
apt_no varchar(50),
apt_type varchar(50),
t_arrear varchar(50),
rent int(50),
PRIMARY KEY (t_id),
FOREIGN KEY (apt_no) REFERENCES apartments(apt_no)
);
CREATE TABLE rent (
r_date date,
t_id varchar(50),
apt_no varchar(50),
r_payment_method varchar(50),
t_arrear varchar(50),
rent int(50),
PRIMARY KEY (r_date),
FOREIGN KEY (t_id) REFERENCES tenant(t_id)
);
CREATE TABLE complaints (
c_no varchar(50),
apt_no varchar(50),
t_id varchar(50),
c_type varchar(50),
c_text varchar(250),
c_status varchar(50),
PRIMARY KEY (c_no),
FOREIGN KEY (t_id) REFERENCES tenant(t_id)
);