summaryrefslogtreecommitdiff
path: root/SCHEMA.sql
blob: b88215af9a6d6087e5f88f6595a0fec0820edc67 (plain)
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
DROP TABLE users, questions, answers, questionaires, quiz_links;
CREATE TABLE users (
	id SERIAL PRIMARY KEY,
	nick TEXT,
	created INT
);
CREATE TABLE questions (
	id SERIAL PRIMARY KEY,
	question TEXT,
	neg_answer TEXT,
	pos_answer TEXT,
	created INT
);
CREATE TABLE answers (
	id SERIAL PRIMARY KEY,
	user_id INT,
	question_id INT,
	answer INT,
	created INT
);
CREATE TABLE questionaires (
	id SERIAL PRIMARY KEY,
	questionset INT[] DEFAULT '{}',
	creator_id INT,
	created INT
);
CREATE TABLE quiz_links (
	id SERIAL PRIMARY KEY,
	quiz_id INT,
	link TEXT,
	created INT
);
INSERT INTO users (nick, created) VALUES ('Raili Niemi', 57 );
INSERT INTO users (nick, created) VALUES ('Tea Jalava', 36 );
INSERT INTO users (nick, created) VALUES ('Eero Metsäranta', 47 );
INSERT INTO questions (question, neg_answer, pos_answer, created)
	VALUES ('Mikä ikä?', '0', '100', 99 );
INSERT INTO questions (question, neg_answer, pos_answer, created)
	VALUES ('Mikä vointi?', 'huono', 'hyvä', 99 );
INSERT INTO questions (question, neg_answer, pos_answer, created)
	VALUES ('Ulkoiletko?', 'viime vuonna', 'joka päivä', 99 );
INSERT INTO questions (question, neg_answer, pos_answer, created)
	VALUES ('kys?', 'ei vielä', 'ei koskaan', 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (1, 1, 570, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (1, 2, 670, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (1, 3, 888, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (1, 4, 999, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (2, 1, 360, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (2, 2, 230, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (2, 3, 120, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (2, 4, 123, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (3, 1, 470, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (3, 2, 570, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (3, 3, 321, 99 );
INSERT INTO answers (user_id, question_id, answer, created)
	VALUES (3, 4, 785, 99 );
INSERT INTO questionaires (questionset,	creator_id, created)
	VALUES ('{1,2,3,4}', 1, 666);
INSERT INTO quiz_links (quiz_id, link, created)
	VALUES (1, 'kyselama', 666);