-
Notifications
You must be signed in to change notification settings - Fork 0
/
putian (1).sql
92 lines (73 loc) · 2.2 KB
/
putian (1).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
CREATE TABLE "Villages" (
"UID_V" char PRIMARY KEY,
"name" varchar,
"name_zh" varchar,
"population" integer,
"geometry" geometry,
"irrigation_region" varchar
);
CREATE TABLE "Alliances" (
"UID_A" char PRIMARY KEY,
"name" varchar,
"name_zh" varchar,
"Geometry" geometry
);
CREATE TABLE "Alliance_Villages" (
"UID_V" char PRIMARY KEY,
"UID_A" char
);
CREATE TABLE "Admin_Village" (
"UID_V" char PRIMARY KEY,
"name" varchar,
"name_zh" varchar
);
CREATE TABLE "Temples" (
"id" SERIAL PRIMARY KEY,
"name" varchar,
"name_zh" varchar,
"UID_V" char
);
CREATE TABLE "Surname_Groups" (
"id" SERIAL PRIMARY KEY,
"UID_V" char,
"surname" char,
"surname_zh" char,
"main_or_not" boolean
);
CREATE TABLE "Raw_Text_Village" (
"UID_V" char PRIMARY KEY,
"village_settlement" text,
"surname_group" text,
"village_temples" text,
"Ritual_processions" text,
"Ritual_Birthdays" text
);
CREATE TABLE "Yuanxiao_Processions" (
"id" SERIAL PRIMARY KEY,
"UID_V" char,
"date" date,
"gods_involved" varchar,
"Text" text
);
CREATE TABLE "Birthday_Celebrations" (
"id" SERIAL PRIMARY KEY,
"UID_V" char,
"date" date,
"gods_involved" varchar,
"Text" text
);
CREATE TABLE "God_Aliases" (
"id" SERIAL PRIMARY KEY,
"alias" varchar,
"databse_name" varchar
);
ALTER TABLE "Alliance_Villages" ADD FOREIGN KEY ("UID_V") REFERENCES "Villages" ("UID_V");
ALTER TABLE "Alliance_Villages" ADD FOREIGN KEY ("UID_A") REFERENCES "Alliances" ("UID_A");
ALTER TABLE "Admin_Village" ADD FOREIGN KEY ("UID_V") REFERENCES "Villages" ("UID_V");
ALTER TABLE "Temples" ADD FOREIGN KEY ("UID_V") REFERENCES "Villages" ("UID_V");
ALTER TABLE "Surname_Groups" ADD FOREIGN KEY ("UID_V") REFERENCES "Villages" ("UID_V");
ALTER TABLE "Raw_Text_Village" ADD FOREIGN KEY ("UID_V") REFERENCES "Villages" ("UID_V");
ALTER TABLE "Yuanxiao_Processions" ADD FOREIGN KEY ("UID_V") REFERENCES "Villages" ("UID_V");
ALTER TABLE "Yuanxiao_Processions" ADD FOREIGN KEY ("gods_involved") REFERENCES "God_Aliases" ("alias");
ALTER TABLE "Birthday_Celebrations" ADD FOREIGN KEY ("UID_V") REFERENCES "Villages" ("UID_V");
ALTER TABLE "Birthday_Celebrations" ADD FOREIGN KEY ("gods_involved") REFERENCES "God_Aliases" ("alias");