-
Notifications
You must be signed in to change notification settings - Fork 0
/
location-db.sql
90 lines (72 loc) · 1.91 KB
/
location-db.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
create table countries
(
id integer not null
constraint countries_pk
primary key,
country_tag varchar(4)
);
alter table countries owner to service;
create unique index countries_country_tag_uindex
on countries (country_tag);
create table province
(
province_id serial not null
constraint province_pk
primary key,
country_id integer
constraint province_countries_id_fk
references countries,
province_name varchar(128)
);
alter table province owner to service;
create index province_country_id_index
on province (country_id);
create table districts
(
district_id integer not null
constraint districts_pk
primary key,
province_id integer
constraint districts_province_province_id_fk
references province,
district_name varchar(128)
);
alter table districts owner to service;
create index districts_district_name_index
on districts (district_name);
create index districts_province_id_index
on districts (province_id);
create table neighborhoods
(
neighborhood_id serial not null
constraint neighborhoods_pk
primary key,
district_id integer
constraint neighborhoods_districts_district_id_fk
references districts,
neighborhood_name varchar(128),
postal_code varchar(16),
latitude numeric(10,8),
longitude numeric(11,8)
);
alter table neighborhoods owner to service;
create index neighborhoods_district_id_index
on neighborhoods (district_id);
create index neighborhoods_longitude_latitude_index
on neighborhoods (longitude, latitude);
create index neighborhoods_postal_code_index
on neighborhoods (postal_code);
create table spatial_ref_sys
(
srid integer not null
constraint spatial_ref_sys_pkey
primary key
constraint spatial_ref_sys_srid_check
check ((srid > 0) AND (srid <= 998999)),
auth_name varchar(256),
auth_srid integer,
srtext varchar(2048),
proj4text varchar(2048)
);
alter table spatial_ref_sys owner to service;
grant select on spatial_ref_sys to public;