-
Notifications
You must be signed in to change notification settings - Fork 1
/
createTables.sql.bak
238 lines (195 loc) · 7.42 KB
/
createTables.sql.bak
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
DROP TABLE IF EXISTS userauthenticate;
CREATE TABLE IF NOT EXISTS userauthenticate (
userid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
username VARCHAR(25) NOT NULL,
password VARCHAR(50) NULL DEFAULT NULL,
approved INTEGEREGER(1) NULL DEFAULT 0,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
lastlogin DATETIME NULL DEFAULT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS uc_username ON userauthenticate (username ASC);
DROP TABLE IF EXISTS certifications;
CREATE TABLE IF NOT EXISTS certifications (
certificationid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
userid INTEGER(11) NOT NULL,
cname VARCHAR(50) NULL DEFAULT NULL,
cauthority VARCHAR(50) NULL DEFAULT NULL,
clicensenumber VARCHAR(50) NULL DEFAULT NULL,
curl VARCHAR(50) NULL DEFAULT NULL,
cstartdate DATE NULL DEFAULT NULL,
cenddate DATE NULL DEFAULT NULL,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT certifications_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid)
);
CREATE INDEX IF NOT EXISTS fk_userid ON certifications (userid ASC);
DROP TABLE IF EXISTS posts ;
CREATE TABLE IF NOT EXISTS posts (
userid INTEGER(11) NOT NULL,
postid INTEGER(11) NOT NULL PRIMARY KEY AUTOINCREMENT,
postheadline VARCHAR(25) NULL DEFAULT NULL,
postbody VARCHAR(1000) NULL DEFAULT NULL,
likes INTEGER(11) NULL DEFAULT '0',
comments INTEGER(11) NULL DEFAULT '0',
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT posts_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid)
);
CREATE INDEX IF NOT EXISTS fk_userid ON posts (userid ASC);
DROP TABLE IF EXISTS comments ;
CREATE TABLE IF NOT EXISTS comments (
postid INTEGER(11) NOT NULL,
commentid INTEGER(11) NOT NULL PRIMARY KEY AUTOINCREMENT,
userid INTEGER(11) NOT NULL,
commentbody VARCHAR(250) NULL DEFAULT NULL,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT comments_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid),
CONSTRAINT comments_ibfk_2
FOREIGN KEY (postid)
REFERENCES posts (postid)
);
CREATE INDEX IF NOT EXISTS fk_userid ON comments (userid ASC);
CREATE INDEX IF NOT EXISTS fk_postid ON comments (postid ASC);
DROP TABLE IF EXISTS education ;
CREATE TABLE IF NOT EXISTS education (
educationid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
userid INTEGER(11) NOT NULL,
school VARCHAR(50) NULL DEFAULT NULL,
startdate DATE NULL DEFAULT NULL,
enddate DATE NULL DEFAULT NULL,
currentlydoing INTEGER(1) NULL DEFAULT '0',
degree VARCHAR(50) NULL DEFAULT NULL,
field VARCHAR(50) NULL DEFAULT NULL,
grade DECIMAL(4,1) NULL DEFAULT NULL,
activities VARCHAR(250) NULL DEFAULT NULL,
description VARCHAR(1000) NULL DEFAULT NULL,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT education_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid));
CREATE INDEX IF NOT EXISTS education_ibfk_1 ON education (userid ASC);
DROP TABLE IF EXISTS experience ;
CREATE TABLE IF NOT EXISTS experience (
userid INTEGER(11) NOT NULL,
experienceid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
companyname VARCHAR(100) NULL DEFAULT NULL,
title VARCHAR(50) NULL DEFAULT NULL,
location VARCHAR(50) NULL DEFAULT NULL,
startdate DATE NULL DEFAULT NULL,
enddate DATE NULL DEFAULT NULL,
currentlyworking INTEGER(1) NULL DEFAULT '0',
description VARCHAR(1000) NULL DEFAULT NULL,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT experience_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid)
);
CREATE INDEX IF NOT EXISTS experience_ibfk_1 ON experience (userid ASC);
DROP TABLE IF EXISTS following ;
CREATE TABLE IF NOT EXISTS following (
userid INTEGER(11) NOT NULL,
category TEXT CHECK(category IN ('company','school') ) NULL DEFAULT NULL,
organisationid INTEGER(11) NULL DEFAULT NULL,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT following_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid),
CONSTRAINT following_ibfk_2
FOREIGN KEY (organisationid)
REFERENCES userauthenticate (userid)
);
CREATE INDEX IF NOT EXISTS fk_userid ON following (userid ASC);
CREATE INDEX IF NOT EXISTS fk_organisationid ON following (organisationid ASC);
DROP TABLE IF EXISTS honorsandawards ;
CREATE TABLE IF NOT EXISTS honorsandawards (
userid INTEGER(11) NOT NULL,
title VARCHAR(50) NULL DEFAULT NULL,
occupation VARCHAR(50) NULL DEFAULT NULL,
issuer VARCHAR(50) NULL DEFAULT NULL,
dateofissue DATE NULL DEFAULT NULL,
description VARCHAR(250) NULL DEFAULT NULL,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT honorsandawards_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid)
);
CREATE INDEX IF NOT EXISTS fk_userid ON honorsandawards (userid ASC);
-- -----------------------------------------------------
-- Table languages
-- -----------------------------------------------------
DROP TABLE IF EXISTS languages;
CREATE TABLE IF NOT EXISTS languages (
userid INTEGER(11) NOT NULL,
languages VARCHAR(25) NULL DEFAULT NULL,
proficiency VARCHAR(25) NULL DEFAULT NULL,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT languages_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid)
);
CREATE INDEX IF NOT EXISTS fk_userid ON languages (userid ASC);
-- -----------------------------------------------------
-- Table likes
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS likes (
postid INTEGER(11) NOT NULL,
userid INTEGER(11) NOT NULL,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT likes_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid),
CONSTRAINT likes_ibfk_2
FOREIGN KEY (postid)
REFERENCES posts (postid)
);
CREATE INDEX IF NOT EXISTS fk_userid ON likes (userid ASC);
CREATE INDEX IF NOT EXISTS fk_postid ON likes (postid ASC);
-- -----------------------------------------------------
-- Table organisation
-- -----------------------------------------------------
DROP TABLE IF EXISTS organisation ;
CREATE TABLE IF NOT EXISTS organisation (
userid INTEGER(11) NULL DEFAULT NULL,
organisationname VARCHAR(50) NULL DEFAULT NULL,
organisationtype TEXT CHECK(organisationtype IN ('company','school') ) NULL DEFAULT NULL,
photo VARCHAR(50) NULL DEFAULT NULL,
following INTEGER(11) NULL DEFAULT NULL,
creationdate DATE NULL DEFAULT NULL,
modifydate DATE NULL DEFAULT NULL,
CONSTRAINT organisation_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid)
);
CREATE INDEX IF NOT EXISTS fk_userid ON organisation (userid ASC);
-- -----------------------------------------------------
-- Table userdetails
-- -----------------------------------------------------
DROP TABLE IF EXISTS userdetails ;
CREATE TABLE IF NOT EXISTS userdetails (
userid INTEGER(11) NOT NULL,
firstname VARCHAR(25) NULL DEFAULT NULL,
lastname VARCHAR(25) NULL DEFAULT NULL,
email VARCHAR(40) NULL DEFAULT NULL,
photo VARCHAR(50) NULL DEFAULT NULL,
country VARCHAR(50) NULL DEFAULT NULL,
state VARCHAR(50) NULL DEFAULT NULL,
city VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (userid),
CONSTRAINT userdetails_ibfk_1
FOREIGN KEY (userid)
REFERENCES userauthenticate (userid)
);