-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path001-iso-639.sql
98 lines (79 loc) · 2.32 KB
/
001-iso-639.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
CREATE TABLE iso_639_5 (
id text NOT NULL PRIMARY KEY,
name text NOT NULL
);
-- ---------------------------------------------------------------------------
CREATE TABLE iso_639_2 (
t_id text NOT NULL PRIMARY KEY,
b_id text NOT NULL UNIQUE,
part1 text NULL UNIQUE,
name text NOT NULL,
reserved boolean NOT NULL DEFAULT false
);
-- ---------------------------------------------------------------------------
CREATE TABLE iso_639_3_scope (
scope text NOT NULL PRIMARY KEY
);
INSERT INTO iso_639_3_scope
(scope)
VALUES
('individual'),
('macrolanguage'),
('special');
-- ---------------------------------------------------------------------------
CREATE TABLE iso_639_3_type (
type text NOT NULL PRIMARY KEY
);
INSERT INTO iso_639_3_type
(type)
VALUES
('ancient'),
('constructed'),
('extinct'),
('historical'),
('living'),
('special');
-- ---------------------------------------------------------------------------
CREATE TABLE iso_639_3 (
id text NOT NULL PRIMARY KEY,
part2t text NULL REFERENCES iso_639_2 (t_id),
part1 text NULL UNIQUE,
scope text NOT NULL REFERENCES iso_639_3_scope (scope),
type text NOT NULL REFERENCES iso_639_3_type (type),
name text NOT NULL,
comment text
);
-- ---------------------------------------------------------------------------
CREATE TABLE iso_639_3_name (
id text NOT NULL REFERENCES iso_639_3 (id),
print text NOT NULL,
inverted text NOT NULL,
PRIMARY KEY (id, print)
);
-- ---------------------------------------------------------------------------
CREATE TABLE iso_639_3_macrolanguage (
m_id text NOT NULL,
i_id text NOT NULL,
PRIMARY KEY (m_id, i_id)
);
-- ---------------------------------------------------------------------------
CREATE TABLE iso_639_3_deprecation_reason (
reason text NOT NULL PRIMARY KEY
);
INSERT INTO iso_639_3_deprecation_reason
(reason)
VALUES
('change'),
('duplicate'),
('merge'),
('nonexistent'),
('split');
-- ---------------------------------------------------------------------------
CREATE TABLE iso_639_3_deprecation (
id text NOT NULL,
reason text NULL REFERENCES iso_639_3_deprecation_reason (reason),
change_to text NULL,
remedy text NULL,
effective_on date NOT NULL,
PRIMARY KEY (id, effective_on)
);