-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathumineko-ddl.sql
78 lines (64 loc) · 1.99 KB
/
umineko-ddl.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
BEGIN;
CREATE TABLE IF NOT EXISTS public.characters
(
character_id integer NOT NULL,
first_name text NOT NULL,
last_name text,
character_type_id integer NOT NULL,
damage_stat integer,
"description" text NOT NULL,
PRIMARY KEY (character_id)
);
CREATE TABLE IF NOT EXISTS public.arcs
(
arc_id integer NOT NULL,
arc_category_id integer NOT NULL,
"name" text NOT NULL,
"description" text NOT NULL,
PRIMARY KEY (arc_id)
);
CREATE TABLE IF NOT EXISTS public.characters_types
(
character_type_id integer NOT NULL,
"type" text NOT NULL,
PRIMARY KEY (character_type_id)
);
CREATE TABLE IF NOT EXISTS public.arcs_categories
(
arc_category_id integer NOT NULL,
"name" text NOT NULL,
"description" text NOT NULL,
PRIMARY KEY (arc_category_id)
);
CREATE TABLE IF NOT EXISTS public.arcs_characters
(
arcs_characters_id serial NOT NULL,
arc_id integer NOT NULL,
character_id integer NOT NULL,
PRIMARY KEY (arcs_characters_id)
);
ALTER TABLE IF EXISTS public.characters
ADD CONSTRAINT fk_characters_characters_types_character_type_id FOREIGN KEY (character_type_id)
REFERENCES public.characters_types (character_type_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE IF EXISTS public.arcs
ADD CONSTRAINT fk_arcs_arcs_categories_arc_category_id FOREIGN KEY (arc_category_id)
REFERENCES public.arcs_categories (arc_category_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE IF EXISTS public.arcs_characters
ADD CONSTRAINT fk_arcs_characters_arcs_arc_id FOREIGN KEY (arc_id)
REFERENCES public.arcs (arc_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE IF EXISTS public.arcs_characters
ADD CONSTRAINT fk_arcs_characters_characters_character_id FOREIGN KEY (character_id)
REFERENCES public.characters (character_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
END;