-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdb.sql
More file actions
39 lines (34 loc) · 991 Bytes
/
db.sql
File metadata and controls
39 lines (34 loc) · 991 Bytes
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
CREATE DATABASE dev_planner;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
--users
CREATE TABLE users(
user_id uuid DEFAULT uuid_generate_v4(),
user_fname VARCHAR(50) NOT NULL,
user_lname VARCHAR(50) NOT NULL,
username VARCHAR(50) NOT NULL UNIQUE,
user_email VARCHAR(50) NOT NULL UNIQUE,
user_password VARCHAR(250) NOT NULL,
user_role VARCHAR(8) NOT NULL,
PRIMARY KEY (user_id)
);
--drafts
CREATE TABLE drafts (
draft_id SERIAL,
user_id UUID,
draft_title VARCHAR(100),
draft_text VARCHAR(1000),
PRIMARY KEY (draft_id),
FOREIGN KEY (user_id) REFERENCES users(user_id)
);
CREATE TABLE messages (
message_id SERIAL,
sender_id UUID,
receipient_id UUID,
sender_username VARCHAR,
message_title VARCHAR(100),
message_text VARCHAR(1000),
PRIMARY KEY (message_id),
FOREIGN KEY (sender_id) REFERENCES users(user_id),
FOREIGN KEY (receipient_id) REFERENCES users(user_id),
FOREIGN KEY (sender_username) REFERENCES users(username)
);