forked from rpp32-sdc-saline/questions_answers-API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
37 lines (31 loc) · 1.18 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
DROP DATABASE IF EXISTS sdc;
CREATE DATABASE sdc WITH OWNER = root;
\connect sdc;
CREATE TABLE questions (
product_id INTEGER NOT NULL,
question_id INTEGER PRIMARY KEY NOT NULL,
question_body TEXT NOT NULL,
question_date TEXT NOT NULL,
asker_name TEXT NOT NULL,
question_helpfulness INTEGER NOT NULL,
reported BOOLEAN NOT NULL
);
CREATE TABLE answers (
question_id INTEGER NOT NULL,
id INTEGER PRIMARY KEY NOT NULL,
body TEXT NOT NULL,
date TEXT NOT NULL,
answerer_name TEXT NOT NULL,
helpfulness INTEGER NOT NULL,
reported BOOLEAN NOT NULL
);
CREATE TABLE answers_photos (
photo_id INTEGER PRIMARY KEY NOT NULL,
answer_id INTEGER NOT NULL,
url TEXT NOT NULL
);
CREATE TABLE photos (
id SERIAL NOT NULL,
answer_id INTEGER PRIMARY KEY NOT NULL,
photos JSONB NOT NULL
);