-
Notifications
You must be signed in to change notification settings - Fork 8
/
estat_codelist_datasets.sql
64 lines (57 loc) · 2.28 KB
/
estat_codelist_datasets.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
CREATE TABLE "ESTAT"."V1"."dat_reference_metadata" (
"id" integer NOT NULL IDENTITY (START WITH 1),
"last_update" datetime,
"data_description" long varchar,
"classification_system" long varchar,
"coverage" long varchar,
"stat_concept" long varchar,
"stat_unit" varchar,
"stat_population" varchar,
"reference_area" varchar,
"coverage_time" varchar,
"base_period" varchar,
"measure_unit" varchar,
PRIMARY KEY ("id"),
CONSTRAINT FK_METADATA_LINKINFO FOREIGN KEY ("id") REFERENCES "ESTAT"."V1"."dat_link_info" ("id")
)
CREATE TABLE "ESTAT"."V1"."dat_metadata_links" (
"id" integer NOT NULL IDENTITY (START WITH 1),
"ref_metadata_id" integer,
"link_id" bigint,
"metadata" smallint,
PRIMARY KEY ("id"),
CONSTRAINT FK_METALINK_METADATA FOREIGN KEY ("ref_metadata_id") REFERENCES "ESTAT"."V1"."dat_reference_metadata" ("id"),
CONSTRAINT FK_METALINK_LINK FOREIGN KEY ("link_id") REFERENCES "ESTAT"."V1"."dat_link_info" ("id")
)
CREATE TABLE "ESTAT"."V1"."mod_code_list" (
"id" integer NOT NULL IDENTITY (START WITH 1),
"label" varchar NOT NULL,
"abbreviation" varchar,
"full_title" varchar,
"taxo_elmnt_id" bigint,
"ref_metadata_id" integer,
PRIMARY KEY ("id"),
CONSTRAINT FK_CODE_METADATA FOREIGN KEY ("ref_metadata_id") REFERENCES "ESTAT"."V1"."dat_reference_metadata" ("id"),
CONSTRAINT FK_CODE_TAXO FOREIGN KEY ("taxo_elmnt_id") REFERENCES "ESTAT"."V1"."dat_taxo_elmnt" ("id")
)
CREATE TABLE "ESTAT"."V1"."dat_code_dico" (
"id" bigint NOT NULL IDENTITY (START WITH 1),
"code" varchar NOT NULL,
"label" varchar NOT NULL,
"code_list_id" integer NOT NULL,
PRIMARY KEY ("id"),
CONSTRAINT FK_CODE_DICO FOREIGN KEY ("dico_id") REFERENCES "ESTAT"."V1"."mod_code_list" ("id")
)
CREATE TABLE "ESTAT"."V1"."dat_dataset" (
"id" bigint NOT NULL IDENTITY (START WITH 1),
"label" varchar NOT NULL,
PRIMARY KEY ("id")
)
CREATE TABLE "ESTAT"."V1"."dat_code_dataset" (
"id" bigint NOT NULL IDENTITY (START WITH 1),
"code_id" bigint NOT NULL,
"dataset_id" bigint NOT NULL,
PRIMARY KEY ("id"),
CONSTRAINT FK_CODE_DATASETS FOREIGN KEY ("code_id") REFERENCES "ESTAT"."V1"."dat_code_dico" ("id"),
CONSTRAINT FK_DATASETS_CODE FOREIGN KEY ("dataset_id") REFERENCES "ESTAT"."V1"."dat_dataset" ("id")
)