-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
61 lines (48 loc) · 1.09 KB
/
Copy pathschema.sql
File metadata and controls
61 lines (48 loc) · 1.09 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
-- Create a schema.sql file to make the following database structure
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS quizzes;
DROP TABLE IF EXISTS questions;
DROP TABLE IF EXISTS choices;
DROP TABLE IF EXISTS answers;
CREATE TABLE users(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT
);
-- Users
-- id || name
-- 1 Bob
-- 2 Sam
CREATE TABLE quizzes(
id INTEGER PRIMARY KEY AUTOINCREMENT,
content TEXT
);
-- id || name
-- 1 Geo1
-- 2 Geo2
-- 3 Geo3
CREATE TABLE questions(
id INTEGER PRIMARY KEY AUTOINCREMENT,
content TEXT,
quiz_id INTEGER
);
-- id || content:blob || quiz_id
-- 1 First president? 1
CREATE TABLE choices(
id INTEGER PRIMARY KEY AUTOINCREMENT,
content TEXT,
question_id INTEGER,
correctness INTEGER
);
-- id || content: blob || question_id
-- 1 Washington 1
-- 2 Lincoln 1
-- 3 Batman 1
-- 4 The blob 1
CREATE TABLE answers(
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER,
question_id INTEGER,
choice_id INTEGER
);
-- id || user_id || question_id || choice_id
-- 1 2 (Sam) 1 3