-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatabase.sql
More file actions
91 lines (72 loc) · 2.24 KB
/
database.sql
File metadata and controls
91 lines (72 loc) · 2.24 KB
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
CREATE DATABASE shutterswipe;
--BASED OF DATABASE SCHEMA
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
--User table
CREATE TABLE users (
user_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_name VARCHAR(100) NOT NULL,
user_email VARCHAR(100) NOT NULL,
user_password VARCHAR(100) NOT NULL
);
--User username table
CREATE TABLE user_username (
username VARCHAR(100) PRIMARY KEY NOT NULL,
user_id UUID REFERENCES users(user_id) NOT NULL
);
--User Description table
CREATE TABLE user_description (
user_id UUID REFERENCES users(user_id) NOT NULL,
user_description TEXT
);
--Profile picture table
CREATE TABLE profile_pics (
pic_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES users(user_id) NOT NULL
);
--Picture table
CREATE TABLE pics (
pic_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES users(user_id) NOT NULL,
pic_score INT DEFAULT 0,
created_date TIMESTAMP NOT NULL
);
--User Traits table
CREATE TABLE traits (
trait_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES users(user_id) NOT NULL,
trait_name VARCHAR(100) NOT NULL
);
--Picture labels table
CREATE TABLE labels (
label_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
pic_id UUID REFERENCES pics(pic_id) NOT NULL,
label_name VARCHAR(100) NOT NULL
);
-- NEW --
CREATE TABLE likes (
user_id UUID REFERENCES users(user_id) NOT NULL,
pic_id UUID REFERENCES pics(pic_id) NOT NULL
);
CREATE TABLE dislikes (
user_id UUID REFERENCES users(user_id) NOT NULL,
pic_id UUID REFERENCES pics(pic_id) NOT NULL
);
-- Written in this way so that groups can have the same group name identified by UUID--
CREATE TABLE groups (
group_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
group_name VARCHAR(100) NOT NULL
);
CREATE TABLE group_relations (
group_id UUID REFERENCES groups(group_id) NOT NULL,
user_id UUID REFERENCES users(user_id) NOT NULL
);
CREATE TABLE group_traits (
group_id UUID REFERENCES groups(group_id) NOT NULL,
trait_name VARCHAR(100) NOT NULL
);
CREATE TABLE group_chat_history (
group_id UUID REFERENCES groups(group_id) NOT NULL,
user_id UUID REFERENCES users(user_id) NOT NULL,
message_contents TEXT NOT NULL,
date_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);