-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.sql
103 lines (91 loc) · 2.6 KB
/
seed.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
DROP DATABASE IF EXISTS driver_jobs_db;
CREATE DATABASE driver_jobs_db;
\c driver_jobs_db
-- Table for Users
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(80) UNIQUE NOT NULL,
email VARCHAR(120) UNIQUE NOT NULL,
password_hash VARCHAR(128) NOT NULL,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
role VARCHAR(50) NOT NULL,
license_type VARCHAR(50),
company_name VARCHAR(100)
);
-- Table for Drivers
DROP TABLE IF EXISTS drivers;
CREATE TABLE drivers (
id INTEGER PRIMARY KEY REFERENCES users(id),
assigned_manager_id INTEGER REFERENCES managers(id),
otherJobDetails VARCHAR,
companyID VARCHAR,
driverType VARCHAR,
currentAvailability VARCHAR,
isAssigned BOOLEAN,
FOREIGN KEY (assigned_manager_id) REFERENCES managers(id)
);
-- Table for Driver Jobs
DROP TABLE IF EXISTS driver_jobs;
CREATE TABLE driver_jobs (
id SERIAL PRIMARY KEY,
driver_id INTEGER REFERENCES drivers(id),
job_id INTEGER REFERENCES jobs(id)
);
-- Table for Clients
DROP TABLE IF EXISTS clients;
CREATE TABLE clients (
id INTEGER PRIMARY KEY REFERENCES users(id),
manager_id INTEGER REFERENCES managers(id),
otherJobDetails VARCHAR,
FOREIGN KEY (manager_id) REFERENCES managers(id)
);
-- Table for Jobs
DROP TABLE IF EXISTS jobs;
CREATE TABLE jobs (
id SERIAL PRIMARY KEY,
jobName VARCHAR,
jobDescription VARCHAR,
jobSchedule VARCHAR,
jobRateOfPay VARCHAR,
client_id INTEGER REFERENCES clients(id),
manager_id INTEGER REFERENCES managers(id),
FOREIGN KEY (client_id) REFERENCES clients(id),
FOREIGN KEY (manager_id) REFERENCES managers(id)
);
-- Table for Managers
DROP TABLE IF EXISTS managers;
CREATE TABLE managers (
id INTEGER PRIMARY KEY REFERENCES users(id),
firstName VARCHAR,
lastName VARCHAR,
FOREIGN KEY (id) REFERENCES users(id)
);
-- Table for Dispatchers
DROP TABLE IF EXISTS dispatchers;
CREATE TABLE dispatchers (
id INTEGER PRIMARY KEY REFERENCES users(id),
firstName VARCHAR,
lastName VARCHAR,
manager_id INTEGER NOT NULL REFERENCES managers(id),
FOREIGN KEY (manager_id) REFERENCES managers(id)
);
-- Table for Companies
DROP TABLE IF EXISTS companies;
CREATE TABLE companies (
id SERIAL PRIMARY KEY,
companyName VARCHAR,
name VARCHAR(120) UNIQUE NOT NULL
);
-- Table for Hidden Jobs
DROP TABLE IF EXISTS hidden_jobs;
CREATE TABLE hidden_jobs (
id SERIAL PRIMARY KEY,
jobName VARCHAR,
jobDescription VARCHAR,
jobSchedule VARCHAR,
jobRateOfPay VARCHAR,
otherJobDetails VARCHAR,
isHidden BOOLEAN
);