forked from mitchgre/gregsList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
executable file
·632 lines (541 loc) · 18.3 KB
/
schema.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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
/*
gregsList is a database driven web app to help direct a job hunt.
*/
# drop tables with foreign keys first
drop table if exists company_industry;
drop table if exists postings;
drop table if exists user_schedule;
drop table if exists company_contacts;
drop table if exists user_contacts;
drop table if exists user_goals;
drop table if exists user_industries;
drop table if exists company_locations;
drop table if exists user_locations;
drop table if exists `user_companies`;
drop table if exists `pass`;
drop table if exists `users`;
drop table if exists industries;
# table to contain users of gregsList
create table `users`(
id int primary key unique auto_increment,
`name` varchar(255) unique
)engine=innodb;
# insert base case users
insert into `users` (`name`)
values ("greg"),("mitchell");
# table to contain passwords
# this is a touchy subject, and I consider my implementation here
# crude and naive
create table `pass`(
`word` varchar(255),
`user` int,
foreign key (`user`) references users(id)
on delete set null on update cascade
)engine=innodb;
# include base cases for pass?
insert into `pass` (`user`,`word`)
values (1,"pass"),(2,"1234");
# hash and salt these later, it's just an example,
# we're not storing credit card info
# list of companies
drop table if exists companies;
create table companies(
id int primary key auto_increment,
name varchar(255) unique
# hiring_activity int, # use joins here instead
# url text
) engine=innodb;
# add some base case companies
insert into `companies` (`name`)
values ("Microsoft"),
("Google"),
("US Dept of Energy"),
("Proctor & Gamble"),
("Berkshire Hathaway"),
("Apple"),
("Oregon State University"),
("NASA"),
("NSA"),
("Wikipedia"),
("Yahoo"),
("Facebook"),
("Twitter"),
("Walmart"),
("Coca Cola"),
("Marvel Studios"),
("Disney"),
("United Airlines"),
("Amazon"),
("The Carney Group"),
("Intel"),
("Sanofi"),
("NVIDIA"),
("Qualcomm"),
("General Motors"),
("Infinera"),
("if(we), formally known as Tagged Inc"),
("Epsilon"),
("Monsanto");
# contains relations between users and companies
create table user_companies(
id int primary key unique auto_increment,
`user` int, # references users.id,
company int, # references companies.id
motivation int,
foreign key (`user`) references users(id)
on delete set null on update cascade,
foreign key (`company`) references companies(id)
on delete set null on update cascade
)engine=innodb;
# add some base case user_companies
# the base case example is that the companies.name already exists in
# the companies table.
insert into `user_companies` (`user`,company,`motivation`)
values ( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="Google"),
5
),
( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="NASA"),
5
),
( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="US Dept of Energy"),
5
),
( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="Berkshire Hathaway"),
4
),
( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="United Airlines"),
2
),
( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="Intel"),
3
),
( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="Qualcomm"),
3
),
( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="NVIDIA"),
4
),
( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="General Motors"),
3
),
( # example where the company name is already defined
(select id from `users` where users.name="greg"),
(select id from `companies` where companies.name="The Carney Group"),
1
),
# next user
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Disney"),
4
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Coca Cola"),
3
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Oregon State University"),
3
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="United Airlines"),
2
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Amazon"),
2
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Berkshire Hathaway"),
3
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Wikipedia"),
4
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Facebook"),
4
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Twitter"),
4
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Walmart"),
2
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Intel"),
3
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="NSA"),
3
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Proctor & Gamble"),
3
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Yahoo"),
5
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="US Dept of Energy"),
4
),
( # example where the company name is already defined
(select id from `users` where users.name="mitchell"),
(select id from `companies` where companies.name="Marvel Studios"),
5
);
# in the event that the companies.name isn't defined, will have to
# resort to using php to process the companies.name insertion into
# companies first, and then pass the resulting id into user_companies.
# list of locations
drop table if exists locations;
create table locations(
id int primary key auto_increment,
name varchar(255) unique
)engine=innodb;
# locations base cases
insert into locations (name)
values ("south of france"),
("somewhere over the rainbow"),
("west of the mississippi");
# above are valid examples of why *not* to break down into countries,cities, etc.
# base cases for posting dependencies
insert into locations (name)
values
("Bethlehem, PA"),
("US-PA-Breinigsville"),
("Allentown, PA"),
("San Francisco"),
("K6-San Francisco - Spear St ");
# contains relations between users and locations
create table user_locations(
id int primary key auto_increment,
`user` int, # references users.id,
`location` int, # references locations.id
`motivation` int, #
foreign key (`user`) references users(id)
on delete set null on update cascade,
foreign key (`location`) references locations(id)
on delete set null on update cascade
)engine=innodb;
# user_location base cases
insert into user_locations (`user`,`location`,`motivation`)
values (1,1,3),(1,2,3),(1,3,2),(2,3,4),(2,1,3),(2,2,2);
# contains relations between companies and locations
create table company_locations(
id int primary key auto_increment,
`company` int, # references companies.id,
`location` int, # references locations.id
foreign key (`company`) references companies(id)
on delete set null on update cascade,
foreign key (`location`) references locations(id)
on delete set null on update cascade
)engine=innodb;
# add base cases for company locations
# contains job postings
create table postings(
id int primary key unique auto_increment,
title varchar(255),
url varchar(255),
`user` int,
company int, #references companies.id,
location int, #references location.id,
`source` varchar(255), # this should reference a new table instead?
foreign key (`user`) references users(id)
on delete set null on update cascade,
foreign key (`company`) references companies(id)
on delete set null on update cascade,
foreign key (`location`) references locations(id)
on delete set null on update cascade
)engine=innodb;
# notes:
# couldn't separate postings from user. It was too complicated to
# figure out how to remove postings if they weren't tied to a user id.
# insert some base case postings
insert into `postings` (`user`,`title`,`url`,`company`,`location`,`source`)
values
(1,
"Software Engineer / Application Developer",
"http://www.indeed.com/cmp/The-Carney-Group/jobs/Software-Engineer-Application-Developer-b67c029e9687804f",
20,
4,
"indeed.com"
),
(1,
"IT Support Engineer II",
"https://us-amazon.icims.com/jobs/309767/it-support-engineer-ii/job?mode=job&iis=Indeed&iisn=Indeed+%28Free+Posting%29&mobile=false&width=1455&height=1200&bga=true&needsRedirect=false&jan1offset=-420&jun1offset=-420",
19,
5,
"indeed.com"
),
(1,
"Computer Engineer",
"http://www.infinera.com/career/ourjobs.html?nl=1&jvi=oxTv0fwF,Job&jvs=Indeed&jvk=Job",
26,
6,
"indeed.com"
),
(2,
"Summer 2015 Intern - Software Engineer",
"http://www.indeed.com/viewjob?jk=42c7d94ab47fda67&q=intern+computer+science&l=san+francisco&tk=19ge8en191d3i0qb&from=web&advn=641811570115501&sjdu=ME_qcF1gz2XOe_-MpbFh208rDrQtJktyve_qLEqEOHE&pub=pub-indeed",
27,
7,
"indeed.com"
),
(2,
"Software Engineer Intern-Computer Vision and Machine Learning",
"https://alliancedata.taleo.net/careersection/epsilon/jobdetail.ftl?job=85205&src=JB-10160",
28,
8,
"indeed.com"
);
# list of industries
create table industries(
id int primary key auto_increment,
name varchar(255) unique
)engine=innodb;
# add some base case industries. (Expect these to grow and be somewhat random).
insert into `industries` (`name`)
values ("government"),
("finance"),
("aerospace"),
("medical"),
("media"),
("music"),
("web"),
("education"),
("Agriculture"),
("Food and Drug"),
("automotive"),
("real estate"),
("software engineering"),
("communications"),
("semiconductors"),
("transportation"),
("manufacturing");
# contains relations between companies and industries
create table company_industry(
id int primary key auto_increment,
company int, # references companies.id,
industry int, # references industries.id
foreign key (`company`) references companies(id)
on delete set null on update cascade,
foreign key (`industry`) references industries(id)
on delete set null on update cascade
)engine=innodb;
# add some base case company-industry relations
insert into company_industry (company,industry)
values (2,7), # google-web
(2,5), # google-media
(2,2), # google-finance
(2,13), # google-software engineering
(2,14), # google- communications
(3,1),
(4,10),
(7,1),
(7,8),
(8,1),
(8,3),
(9,1),
(9,13),
(9,14),
(10,7),
(11,7),
(12,7),
(13,7),
(13,5),
(13,13),
(15,10),
(16,5),
(17,5),
(18,16),
(19,7),
(21,17), # manufacturing
(23,17),
(24,17),
(21,15),
(23,15),
(24,15);
# contains relations between users and industries
create table user_industries(
id int primary key auto_increment,
industry int, # references industries.id,
`user` int, # references users.id
foreign key (`industry`) references industries(id)
on delete set null on update cascade,
foreign key (`user`) references users(id)
on delete set null on update cascade
)engine=innodb;
# base case user industries
insert into user_industries (`user`,`industry`)
values (2,7),(1,7),(2,13),(1,13),(1,2),(2,2),(1,14);
# contains goals
drop table if exists goals;
create table goals(
id int primary key auto_increment,
`value` varchar(255)
)engine=innodb;
# base case goals
insert into goals (`value`)
values ("get a better job"),
("find an ideal company"),
("research companies"),
("research industries"),
("find contacts"),
("schedule interviews");
# contains relations between users and goals
create table `user_goals`(
id int primary key auto_increment,
`user` int,# references users.id,
`goal` int,# references goals.id
foreign key (`user`) references users(id)
on delete set null on update cascade,
foreign key (`goal`) references goals(id)
on delete set null on update cascade
)engine=innodb;
# base case user goals
insert into user_goals (`user`,`goal`)
values (1,1),
(1,2),
(1,3),
(1,4),
(1,5),
(1,6),
(2,1),
(2,2),
(2,3),
(2,4),
(2,5),
(2,6);
# contains contacts
drop table if exists contacts;
create table contacts(
id int primary key auto_increment,
fname varchar(255),
lname varchar(255),
email varchar(255),
phone varchar(255),
facebook varchar(255),
linkedin varchar(255),
github varchar(255)
)engine=innodb;
# base case contacts (current instructors this semester)
insert into contacts (fname,lname,email,linkedin,github)
values ("ameneh", "sarbaziazad",
"[email protected]","tbd",
"tbd"
),
( "justin", "wolford",
"[email protected]","tbd",
"wolfordj"
),
(
"samina","ehasan",
"tbd","tbd"
);
# contains relations between users and contacts
create table user_contacts(
id int primary key auto_increment,
`user` int,# references users.id,
contact int,# references contacts.id
foreign key (`user`) references users(id)
on delete set null on update cascade,
foreign key (`contact`) references contacts(id)
on delete set null on update cascade
)engine=innodb;
# base cases
insert into user_contacts (`user`,`contact`)
values (1,1),(1,2),(1,3),
(2,1),(2,2),(2,3);
# contains relations between companies and contacts
create table company_contacts(
id int primary key auto_increment,
`company` int,# references companies.id,
contact int,# references contacts.id
foreign key (`company`) references companies(id)
on delete set null on update cascade,
foreign key (`contact`) references contacts(id)
on delete set null on update cascade
)engine=innodb;
# base cases
insert into company_contacts (`company`,`contact`)
values
((select id from companies where name="Oregon State University"), 1),
((select id from companies where name="Oregon State University"), 2),
((select id from companies where name="Oregon State University"), 3);
# contains schedules
drop table if exists schedule;
create table schedule(
id int primary key auto_increment,
`name` varchar(255),
`description` text,
`location` text,
`contact` text,
`url` text,
`start` datetime,
`end` datetime
)engine=innodb;
# base case schedule
insert into schedule (`name`,`description`,`start`,`end`)
values
(
"write up final project",
"check against guidelines",
"2015-03-14", "2015-03-15"),
(
"study for finals",
"make note page",
"2015-03-15", "2015-03-19");
# contains relations between users and schedules
create table user_schedule(
id int primary key auto_increment,
`user` int,# references users.id,
`schedule` int,# references schedule.id
foreign key (`user`) references users(id)
on delete set null on update cascade,
foreign key (`schedule`) references schedule(id)
on delete set null on update cascade
);
# base case
insert into user_schedule (`user`,`schedule`)
values (1,1), (1,2),
(2,1), (2,2);