-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtables.sql
122 lines (108 loc) · 2.77 KB
/
tables.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
CREATE TABLE professionCategory(
pid int,
profession VARCHAR(32) DEFAULT 'NONE',
domain VARCHAR(32) DEFAULT 'NONE',
PRIMARY KEY(pid)
);
CREATE TABLE user(
uid int AUTO_INCREMENT,
username VARCHAR(50),
password VARCHAR(50),
name VARCHAR(50),
age int,
aadharNumber bigint UNIQUE,
serviceProvider VARCHAR(5),
pid int,
PRIMARY KEY(uid),
FOREIGN KEY(pid) REFERENCES ProfessionCategory(pid) ON DELETE SET NULL
);
CREATE TABLE location(
lid int,
locality VARCHAR(250),
pin int,
city VARCHAR(50),
PRIMARY KEY(lid)
);
CREATE TABLE address(
uid int,
apartment VARCHAR(250),
lid int,
addressType VARCHAR(50) DEFAULT 'HOME',
PRIMARY KEY(uid, apartment),
FOREIGN KEY(uid) REFERENCES user(uid) ON DELETE CASCADE,
FOREIGN KEY(lid) REFERENCES location(lid) ON DELETE SET NULL
);
CREATE TABLE favourites(
uidSS int, -- SS -> Service Seeker
uidSP int, -- SP -> Service Provider
PRIMARY KEY(uidSS, uidSP),
FOREIGN KEY(uidSS) REFERENCES user(uid) ON DELETE CASCADE,
FOREIGN KEY(uidSP) REFERENCES user(uid) ON DELETE CASCADE
);
CREATE TABLE phoneNumber(
uid int,
phoneNumber int,
PRIMARY KEY(uid, phoneNumber),
FOREIGN KEY(uid) REFERENCES user(uid) ON DELETE CASCADE
);
CREATE TABLE sosNumber(
uid int,
phoneNumber int,
PRIMARY KEY(uid, phoneNumber),
FOREIGN KEY(uid) REFERENCES user(uid) ON DELETE CASCADE
);
CREATE TABLE ratingsAndReviews(
uidSS int, -- SS -> Service Seeker
uidSP int, -- SP -> Service Provider
rating int,
review VARCHAR(500),
PRIMARY KEY(uidSS, uidSP),
FOREIGN KEY(uidSS) REFERENCES user(uid) ON DELETE CASCADE,
FOREIGN KEY(uidSP) REFERENCES user(uid) ON DELETE CASCADE
);
CREATE TABLE employee(
eid int,
name VARCHAR(32),
designation VARCHAR(32),
availability VARCHAR(15),
PRIMARY KEY(eid)
);
CREATE TABLE complaints(
cid int,
uidSS int, -- SS -> Service Seeker
uidSP int, -- SP -> Service Provider
complaint VARCHAR(200),
eid int,
PRIMARY KEY(cid),
FOREIGN KEY(uidSS) REFERENCES user(uid) ON DELETE CASCADE,
FOREIGN KEY(uidSP) REFERENCES user(uid) ON DELETE CASCADE,
FOREIGN KEY(eid) REFERENCES employee(eid) ON DELETE CASCADE
);
CREATE TABLE blacklist(
aadharNumber int PRIMARY KEY
);
show tables;
/*
DESCRIBE professionCategory;
DESCRIBE user
DESCRIBE location
DESCRIBE address
DESCRIBE favourites
DESCRIBE phoneNumber
DESCRIBE sosNumber
DESCRIBE ratingsAndReviews
DESCRIBE employee
DESCRIBE complaints
DESCRIBE blacklist
DROP TABLE professionCategory;
DROP TABLE user;
DROP TABLE location;
DROP TABLE address;
DROP TABLE favourites;
DROP TABLE phoneNumber;
DROP TABLE sosNumber;
DROP TABLE ratingsAndReviews;
DROP TABLE employee;
DROP TABLE complaints;
DROP TABLE blacklist;
*/