-
Notifications
You must be signed in to change notification settings - Fork 2
/
database.sql
42 lines (35 loc) · 932 Bytes
/
database.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
-- USER is a reserved keyword with Postgres
-- You must use double quotes in every query that user is in:
-- ex. SELECT * FROM "user";
-- Otherwise you will have errors!
CREATE TABLE "user" (
"id" SERIAL PRIMARY KEY,
"username" VARCHAR (80) UNIQUE NOT NULL,
"password" VARCHAR (1000) NOT NULL
);
CREATE TABLE watchlist (
"id" SERIAL PRIMARY KEY,
"user_id" INT NOT NULL,
FOREIGN KEY (user_id) REFERENCES "user"(id),
"ticker" VARCHAR(6) UNIQUE NOT NULL,
"mentions" INT
);
-- DUMMY DATA for Watchist
INSERT INTO "watchlist" (user_id, ticker, mentions)
VALUES
(2, 'AAPL', 1576),
(2, 'TSLA', 960),
(2, 'AMD', 581),
(2, 'MSFT', 450),
(2, 'NVDA', 284);
CREATE TABLE articles (
"id" SERIAL PRIMARY KEY,
"user_id" INT NOT NULL,
FOREIGN KEY (user_id) REFERENCES "user"(id),
"date" VARCHAR(50),
"title" VARCHAR(255),
"ticker" VARCHAR(50),
"mentions" VARCHAR(255),
"score" VARCHAR(50),
"link" VARCHAR(255)
);