-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
111 lines (101 loc) · 2.8 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
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
101
102
103
104
105
106
107
108
109
110
111
PRAGMA foreign_keys = ON;
DROP TABLE IF EXISTS character;
CREATE TABLE character (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
hp INT NOT NULL,
max_hp INT NOT NULL,
ac INT NOT NULL,
iniative INT NOT NULL,
speed INT NOT NULL,
proficiency INT NOT NULL,
img TEXT
);
DROP TABLE IF EXISTS ability;
CREATE TABLE ability (
id INTEGER PRIMARY KEY AUTOINCREMENT,
character_id INT NOT NULL,
name TEXT NOT NULL,
score INT NOT NULL,
proficient BOOLEAN NOT NULL,
FOREIGN KEY(character_id) REFERENCES character(id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS skill;
CREATE TABLE skill (
id INTEGER PRIMARY KEY AUTOINCREMENT,
character_id INT NOT NULL,
name TEXT NOT NULL,
score INT NOT NULL,
proficient BOOLEAN NOT NULL,
FOREIGN KEY(character_id) REFERENCES character(id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS purse;
CREATE TABLE purse (
id INTEGER PRIMARY KEY AUTOINCREMENT,
character_id INT NOT NULL,
cp INT NOT NULL,
sp INT NOT NULL,
ep INT NOT NULL,
gp INT NOT NULL,
pp INT NOT NULL,
FOREIGN KEY(character_id) REFERENCES character(id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS note;
CREATE TABLE note (
id INTEGER PRIMARY KEY AUTOINCREMENT,
character_id INT NOT NULL,
title TEXT NOT NULL,
body TEXT NOT NULL,
FOREIGN KEY(character_id) REFERENCES character(id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS item;
CREATE TABLE item (
id INTEGER PRIMARY KEY AUTOINCREMENT,
character_id INT NOT NULL,
name TEXT NOT NULL,
weight REAL NOT NULL,
description TEXT,
weapon BOOLEAN NOT NULL,
damage TEXT,
count INT NOT NULL,
FOREIGN KEY(character_id) REFERENCES character(id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS encounter;
CREATE TABLE encounter (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
useMap TEXT NOT NULL,
grid INT
);
DROP TABLE IF EXISTS encounter_monster;
CREATE TABLE encounter_monster (
id INTEGER PRIMARY KEY AUTOINCREMENT,
encounter_id INT NOT NULL,
name TEXT NOT NULL,
size INT NOT NULL,
hp INT NOT NULL,
x INT NOT NULL,
y INT NOT NULL,
useLocal BOOLEAN Not NULL,
FOREIGN KEY(encounter_id) REFERENCES encounter(id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS location;
CREATE TABLE location (
id INTEGER PRIMARY KEY AUTOINCREMENT,
encounter_id INT NOT NULL,
character_id INT NOT NULL,
x INT NOT NULL,
y INT NOT NULL,
FOREIGN KEY(encounter_id) REFERENCES encounter(id) ON DELETE CASCADE,
FOREIGN KEY(character_id) REFERENCES character(id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS terrain;
CREATE TABLE terrain (
id INTEGER PRIMARY KEY AUTOINCREMENT,
encounter_id INT NOT NULL,
x INT NOT NULL,
y INT NOT NULL,
width INT NOT NULL,
height INT NOT NULL,
FOREIGN KEY(encounter_id) REFERENCES encounter(id) ON DELETE CASCADE
);