· 5 years ago · Feb 12, 2020, 01:18 PM
1create table atmos_metric (
2 metric_id int not null,
3 metric_display_name varchar(128) not null,
4 metric_maxrows int not null,
5 metric_maxcols int not null,
6 primary key (metric_id)
7);
8
9create table atmos_sensor (
10 sensor_id int not null,
11 sensor_org varchar(45) null,
12 sensor_entry_date varchar(45) not null,
13 primary key (sensor_id)
14);
15
16create table atmos_region (
17 region_id int not null,
18 region_name varchar(45) not null,
19 primary key (region_id)
20);
21
22create table atmos_unit (
23 unit_id int not null,
24 unit_name varchar(45) not null,
25 unit_si_base varchar(128) not null,
26 primary key (unit_id)
27);
28
29create table if not exists mydb.atmos_timestamp (
30 timestamp_id int not null,
31 timestamp_utc int not null,
32 primary key (timestamp_id)
33);
34
35create table atmos_measurement (
36 atmos_metric_metric_id int not null,
37 atmos_timestamp_timestamp_id int not null,
38 atmos_sensor_sensor_id int not null,
39 atmos_region_region_id int not null,
40 atmos_unit_unit_id int not null,
41 mm_value decimal not null,
42 mm_altitude_m int not null,
43 mm_dimensions_col int null,
44 mm_dimensions_row int null,
45 primary key (atmos_metric_metric_id, atmos_timestamp_timestamp_id, atmos_sensor_sensor_id, atmos_region_region_id, atmos_unit_unit_id),
46 index fk_atmos_measurement_atmos_sensor1_idx (atmos_sensor_sensor_id asc) visible,
47 index fk_atmos_measurement_atmos_region1_idx (atmos_region_region_id asc) visible,
48 index fk_atmos_measurement_atmos_unit1_idx (atmos_unit_unit_id asc) visible,
49 index fk_atmos_measurement_atmos_timestamp1_idx (atmos_timestamp_timestamp_id asc) visible,
50 constraint fk_atmos_measurement_atmos_metric
51 foreign key (atmos_metric_metric_id)
52 references mydb.atmos_metric (metric_id)
53 on delete no action
54 on update no action,
55 constraint fk_atmos_measurement_atmos_sensor1
56 foreign key (atmos_sensor_sensor_id)
57 references mydb.atmos_sensor (sensor_id)
58 on delete no action
59 on update no action,
60 constraint fk_atmos_measurement_atmos_region1
61 foreign key (atmos_region_region_id)
62 references mydb.atmos_region (region_id)
63 on delete no action
64 on update no action,
65 constraint fk_atmos_measurement_atmos_unit1
66 foreign key (atmos_unit_unit_id)
67 references mydb.atmos_unit (unit_id)
68 on delete no action
69 on update no action,
70 constraint fk_atmos_measurement_atmos_timestamp1
71 foreign key (atmos_timestamp_timestamp_id)
72 references mydb.atmos_timestamp (timestamp_id)
73 on delete no action
74 on update no action
75);