-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
100 lines (82 loc) · 2.05 KB
/
database.sql
File metadata and controls
100 lines (82 loc) · 2.05 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
90
91
92
93
94
95
96
97
98
99
100
-- 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,
"dob" DATE NOT NULL,
"zip" VARCHAR (5) NOT NULL,
"profile_description" VARCHAR (1000)
);
-- starter dummy data
INSERT INTO "user" (
"username",
"password",
"dob",
"sign",
"zip",
"profile_description"
)
VALUES (
'kit',
'1234',
'04/29/1984',
'55409',
'snuggling a cat and listening to techno are two of my favorite things.'
),
('the_butchelor',
'1234',
'01/23/1983',
'98661',
'Handsome, genderqueer Butchelor hoping to marry rich. Must love cats.'
);
-- DROP TABLE "user";
-- SELECT * FROM "user";
-- CREATE TABLE "messages" (
-- "id" SERIAL PRIMARY KEY,
-- "sender_id" INT REFERENCES "user",
-- "message_text" VARCHAR (1000) NOT NULL,
-- "timestamp" TIME,
-- );
-- create a conversation_id reference column
-- CREATE TABLE "conversations" (
-- "id" SERIAL PRIMARY KEY,
-- "sender_id" INT REFERENCES "user",
-- "recipient_id" INT REFERENCES "user",
-- "message_id" INT REFERENCES "messages"
-- );
-- remove message_ id column
CREATE TABLE "zodiac" (
"id" SERIAL PRIMARY KEY,
"sign_name" VARCHAR,
"sign_description" VARCHAR
);
INSERT INTO "zodiac"("sign_name")
VALUES (
'Capricorn',
'Aquarius',
'Pisces',
'Aries',
'Taurus',
'Gemini',
'Cancer',
'Leo',
'Virgo',
'Libra',
'Scorpio',
'Sagittarius'
);
CREATE TABLE "conversations" (
"id" SERIAL PRIMARY KEY,
"user1" INT REFERENCES "user",
"user2" INT REFERENCES "user"
);
CREATE TABLE "messages" (
"id" SERIAL PRIMARY KEY,
"sender_id" INT REFERENCES "user",
"message_text" VARCHAR (1000) NOT NULL,
"timestamp" TIME,
"convo_id" INT REFERENCES "conversations"
);