forked from eenabow/ETL-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Table_schemata.sql
141 lines (122 loc) · 4.49 KB
/
Table_schemata.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
-- Exported from QuickDBD: https://www.quickdatabasediagrams.com/
-- NOTE! If you have used non-SQL datatypes in your design, you will have to change these here.
CREATE TABLE "country" (
"Country" VARCHAR NOT NULL,
"Country_id" VARCHAR NOT NULL,
CONSTRAINT "pk_country" PRIMARY KEY (
"Country_id"
)
);
CREATE TABLE "vaccinations" (
"Country" VARCHAR NOT NULL,
"Country_id" VARCHAR NOT NULL,
"vaccination_date" date NOT NULL,
"total_vaccinations" int NOT NULL,
"avg_daily_vaccinations" float NOT NULL,
CONSTRAINT "pk_vaccinations" PRIMARY KEY (
"Country_id"
)
);
CREATE TABLE "travel_restrictions" (
"Country" VARCHAR NOT NULL,
"Country_id" VARCHAR NOT NULL,
"Quarantine_type" VARCHAR NOT NULL,
"Quarantine_start_date" date NOT NULL,
CONSTRAINT "pk_travel_restrictions" PRIMARY KEY (
"Country_id"
)
);
CREATE TABLE "full_closures" (
"Policy_id" VARCHAR NOT NULL,
"Country_id" VARCHAR NOT NULL,
"Policy_type" VARCHAR NOT NULL,
"Policy_subtype" VARCHAR NOT NULL,
"Policy_start_date" date NOT NULL,
"Citizen_exceptions" int NOT NULL,
"Citizen_exceptions_info" VARCHAR NOT NULL,
"Country_exceptions" int NOT NULL,
"Country_exceptions_info" VARCHAR NOT NULL,
"Work_exceptions" int NOT NULL,
CONSTRAINT "pk_full_closures" PRIMARY KEY (
"Country_id"
)
);
CREATE TABLE "no_closures" (
"Policy_id" VARCHAR NOT NULL,
"Country" VARCHAR NOT NULL,
"Country_id" VARCHAR NOT NULL,
"Policy_type" VARCHAR NOT NULL,
"Policy_subtype" VARCHAR NOT NULL,
CONSTRAINT "pk_no_closures" PRIMARY KEY (
"Country_id"
)
);
CREATE TABLE "partial_borders" (
"Policy_id" VARCHAR NOT NULL,
"Country_id" VARCHAR NOT NULL,
"Policy_type" VARCHAR NOT NULL,
"Policy_subtype" VARCHAR NOT NULL,
"Policy_start_date" date NOT NULL,
"Air_ban" int NOT NULL,
"Air_ban_type" VARCHAR NOT NULL,
"Air_ban_info" VARCHAR NOT NULL,
"Land_ban" int NOT NULL,
"Land_ban_type" VARCHAR NOT NULL,
"Land_ban_info" VARCHAR NOT NULL,
"Sea_ban" int NOT NULL,
"Sea_ban_type" VARCHAR NOT NULL,
"Sea_ban_info" VARCHAR NOT NULL,
CONSTRAINT "pk_partial_borders" PRIMARY KEY (
"Country_id"
)
);
CREATE TABLE "partial_citizenship" (
"Policy_id" VARCHAR NOT NULL,
"Country_id" VARCHAR NOT NULL,
"Policy_type" VARCHAR NOT NULL,
"Policy_subtype" VARCHAR NOT NULL,
"Policy_start_date" date NOT NULL,
"Citizen_ban_info" VARCHAR NOT NULL,
CONSTRAINT "pk_partial_citizenship" PRIMARY KEY (
"Country_id"
)
);
CREATE TABLE "partial_history" (
"Policy_id" VARCHAR NOT NULL,
"Country_id" VARCHAR NOT NULL,
"Policy_type" VARCHAR NOT NULL,
"Policy_subtype" VARCHAR NOT NULL,
"Policy_start_date" date NOT NULL,
"Travel_history_ban_info" VARCHAR NOT NULL,
CONSTRAINT "pk_partial_history" PRIMARY KEY (
"Country_id"
)
);
CREATE TABLE "partial_visa" (
"Policy_id" VARCHAR NOT NULL,
"Country_id" VARCHAR NOT NULL,
"Policy_type" VARCHAR NOT NULL,
"Policy_subtype" VARCHAR NOT NULL,
"Policy_start_date" date NOT NULL,
"Visa_ban_list" VARCHAR NOT NULL,
"Visa_ban_info" VARCHAR NOT NULL,
CONSTRAINT "pk_partial_visa" PRIMARY KEY (
"Country_id"
)
);
ALTER TABLE "vaccinations" ADD CONSTRAINT "fk_vaccinations_Country_id" FOREIGN KEY("Country_id")
REFERENCES "country" ("Country_id");
ALTER TABLE "travel_restrictions" ADD CONSTRAINT "fk_travel_restrictions_Country_id" FOREIGN KEY("Country_id")
REFERENCES "country" ("Country_id");
ALTER TABLE "full_closures" ADD CONSTRAINT "fk_full_closures_Country_id" FOREIGN KEY("Country_id")
REFERENCES "country" ("Country_id");
ALTER TABLE "no_closures" ADD CONSTRAINT "fk_no_closures_Country_id" FOREIGN KEY("Country_id")
REFERENCES "country" ("Country_id");
ALTER TABLE "partial_borders" ADD CONSTRAINT "fk_partial_borders_Country_id" FOREIGN KEY("Country_id")
REFERENCES "country" ("Country_id");
ALTER TABLE "partial_citizenship" ADD CONSTRAINT "fk_partial_citizenship_Country_id" FOREIGN KEY("Country_id")
REFERENCES "country" ("Country_id");
ALTER TABLE "partial_history" ADD CONSTRAINT "fk_partial_history_Country_id" FOREIGN KEY("Country_id")
REFERENCES "country" ("Country_id");
ALTER TABLE "partial_visa" ADD CONSTRAINT "fk_partial_visa_Country_id" FOREIGN KEY("Country_id")
REFERENCES "country" ("Country_id");