-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_database.sql
46 lines (39 loc) · 1.12 KB
/
create_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
42
43
44
45
46
CREATE TABLE IF NOT EXISTS public.Database (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TYPE public.hand AS ENUM ('L', 'R');
CREATE TYPE public.gender AS ENUM ('M', 'F');
CREATE TABLE IF NOT EXISTS public.Writer (
id SERIAL PRIMARY KEY,
databaseId INTEGER REFERENCES public.Database(id),
name TEXT,
age integer,
gender gender,
hand hand
);
CREATE TABLE IF NOT EXISTS public.Formula (
id SERIAL PRIMARY KEY,
writerId INTEGER REFERENCES public.Writer(id),
formula TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS public.TraceGroup (
id SERIAL PRIMARY KEY,
formulaId INTEGER REFERENCES public.Formula(id),
truth TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS public.Trace (
id SERIAL PRIMARY KEY,
traceGroupId INTEGER REFERENCES public.TraceGroup(id),
trace TEXT
);
CREATE TABLE IF NOT EXISTS public.Format (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
type TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS public.FormulaFormat (
formulaId INTEGER REFERENCES public.Formula(id),
formatId INTEGER REFERENCES public.Format(id),
"order" INTEGER NOT NULL
);