-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_db.sql
65 lines (57 loc) · 1.66 KB
/
create_db.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
CREATE TABLE IF NOT EXISTS companies
(id INTEGER PRIMARY KEY,
company_name TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS titles
(id INTEGER PRIMARY KEY,
title TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS categories
(id INTEGER PRIMARY KEY,
category TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS subcategories
(id INTEGER PRIMARY KEY,
category TEXT NOT NULL,
subcategory TEXT NOT NULL,
FOREIGN KEY (category)
REFERENCES categories (category)
);
CREATE TABLE IF NOT EXISTS geo_area
(id INTEGER PRIMARY KEY,
area TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS jobs
(id INTEGER PRIMARY KEY,
jobindex_id TEXT NOT NULL,
title TEXT NOT NULL,
job_url TEXT NOT NULL,
added TEXT NOT NULL,
expired TEXT NOT NULL,
company TEXT NOT NULL,
job_description TEXT NOT NULL,
FOREIGN KEY (company)
REFERENCES companies (company_name),
FOREIGN KEY (title)
REFERENCES titles (title)
);
CREATE TABLE IF NOT EXISTS job_category
(
id INTEGER PRIMARY KEY,
jobindex_id TEXT NOT NULL,
category TEXT NOT NULL,
subcategory TEXT NOT NULL,
FOREIGN KEY (jobindex_id)
REFERENCES jobs (jobindex_id),
FOREIGN KEY (category)
REFERENCES categories (category),
FOREIGN KEY (subcategory)
REFERENCES subcategories (subcategory)
);
CREATE TABLE IF NOT EXISTS job_area
(
id INTEGER PRIMARY KEY,
jobindex_id TEXT NOT NULL,
area TEXT NOT NULL,
FOREIGN KEY (jobindex_id)
REFERENCES jobs (jobindex_id),
FOREIGN KEY (area)
REFERENCES geo_area (area)
);