Correct index and create if not exists
This commit is contained in:
parent
62b65dc2d8
commit
2bd1e23c1b
1 changed files with 6 additions and 4 deletions
10
weather.sql
10
weather.sql
|
@ -1,4 +1,4 @@
|
||||||
CREATE TABLE `weather` (
|
CREATE TABLE IF NOT EXISTS `weather` (
|
||||||
`observation_id` int NOT NULL AUTO_INCREMENT,
|
`observation_id` int NOT NULL AUTO_INCREMENT,
|
||||||
`date` date DEFAULT NULL,
|
`date` date DEFAULT NULL,
|
||||||
`time` time DEFAULT NULL,
|
`time` time DEFAULT NULL,
|
||||||
|
@ -6,12 +6,13 @@ CREATE TABLE `weather` (
|
||||||
`rel_hum` decimal(10,0) DEFAULT NULL,
|
`rel_hum` decimal(10,0) DEFAULT NULL,
|
||||||
`temp` float DEFAULT NULL,
|
`temp` float DEFAULT NULL,
|
||||||
`windspeed` float DEFAULT NULL,
|
`windspeed` float DEFAULT NULL,
|
||||||
|
`station` int DEFAULT NULL,
|
||||||
`winddir` int DEFAULT NULL,
|
`winddir` int DEFAULT NULL,
|
||||||
PRIMARY KEY (`observation_id`),
|
PRIMARY KEY (`observation_id`),
|
||||||
UNIQUE KEY `date_time_idx` (`date`,`time`)
|
UNIQUE KEY `date_time_idx` (`date`,`time`,`station`)
|
||||||
)
|
)
|
||||||
|
|
||||||
CREATE TABLE `aggregated_weather` (
|
CREATE TABLE IF NOT EXISTS `aggregated_weather` (
|
||||||
`Date_id` int NOT NULL AUTO_INCREMENT,
|
`Date_id` int NOT NULL AUTO_INCREMENT,
|
||||||
`Date` date DEFAULT NULL,
|
`Date` date DEFAULT NULL,
|
||||||
`T_max` float DEFAULT NULL,
|
`T_max` float DEFAULT NULL,
|
||||||
|
@ -22,6 +23,7 @@ CREATE TABLE `aggregated_weather` (
|
||||||
`RH_mean` float DEFAULT NULL,
|
`RH_mean` float DEFAULT NULL,
|
||||||
`Rainfall` float DEFAULT NULL,
|
`Rainfall` float DEFAULT NULL,
|
||||||
`ETo` float DEFAULT NULL,
|
`ETo` float DEFAULT NULL,
|
||||||
|
`station` int DEFAULT NULL,
|
||||||
PRIMARY KEY (`Date_id`),
|
PRIMARY KEY (`Date_id`),
|
||||||
UNIQUE KEY `date_idx` (`Date`)
|
UNIQUE KEY `date_idx` (`Date`,`station`)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue