Repository navigation
Expand file tree
/
Copy pathcpp.sql
More file actions
132 lines (119 loc) · 3.16 KB
/
Copy pathcpp.sql
File metadata and controls
132 lines (119 loc) · 3.16 KB
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
drop table country_content;
drop table region_content;
drop table country_incident;
drop table region_incident;
drop table source;
drop table incident;
drop table incident_type;
drop table region_country;
drop table region;
drop table country;
drop table page;
drop table usr;
create table usr (
id varchar(64) not null,
date_created datetime,
last_updated datetime,
first_name varchar(255),
last_name varchar(255),
email varchar(255),
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table page (
id varchar(64) not null,
date_created datetime,
last_updated datetime,
content text,
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table country (
id varchar(2),
name varchar(255),
lat real,
lon real,
bb_nw_lat real,
bb_nw_lon real,
bb_se_lat real,
bb_se_lon real,
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table region (
id varchar(16),
type varchar(16),
name varchar(255),
lat real,
lon real,
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table region_country (
region varchar(16),
country varchar(2),
foreign key (region) references region(id),
foreign key (country) references country(id),
primary key (region, country)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table source (
id varchar(16) not null,
name varchar(255) not null,
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table incident_type (
id varchar(16) not null,
name varchar(255) not null,
class varchar(255),
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table incident (
id integer auto_increment not null,
date_created datetime,
last_updated datetime,
ts datetime,
ts_end datetime,
type varchar(16),
source varchar(16),
source_id varchar(64),
usr varchar(64),
name varchar(255),
descr text,
lat real,
lon real,
foreign key (type) references incident_type(id),
index incident_sourceid(source_id),
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table country_incident (
incident integer,
country varchar(16),
foreign key (incident) references incident(id) on delete cascade,
foreign key (country) references country(id) on delete cascade,
primary key (incident,country)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table region_incident (
incident integer,
region varchar(16),
foreign key (incident) references incident(id),
foreign key (region) references region(id),
primary key (incident,region)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table country_content (
country varchar(2) not null,
id varchar(16) not null,
date_created datetime,
last_updated datetime,
content text,
usr varchar(64) not null,
foreign key (country) references country(id),
foreign key (usr) references usr(id),
primary key (country, id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table region_content (
region varchar(16) not null,
id varchar(16) not null,
date_created datetime,
last_updated datetime,
content text,
usr varchar(64) not null,
foreign key (region) references region(id),
foreign key (usr) references usr(id),
primary key (region, id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;