-- DBMS: bigquery
CREATE TABLE `bigquery-public-data.noaa_historic_severe_storms.tornado_paths`
(
  storm_date DATE OPTIONS(description="Date of the tornado"),
  storm_time TIME OPTIONS(description="Time of the tornado"),
  time_zone_offset STRING OPTIONS(description="Timezone offset of where the the tornado occurred. Possible values are -06:00 (CST), -00:00 (GMT/UTC), and unknown"),
  state_abbreviation STRING OPTIONS(description="2 letter postal abbreviation of the state's name"),
  state_name STRING OPTIONS(description="Full text name of the state in which the tornado occurred"),
  state_fips_code STRING OPTIONS(description="2-digit state FIPS code. This maps to all state_fips_code columns in the BigQuery Public Datasets Program"),
  magnitude STRING OPTIONS(description="EF-Scale rating for the tornado. Possible values are 0, 1, 2, 3, 4 , 5 and unknown"),
  injured_count INT64 OPTIONS(description="Number of people injured as a result of the storm"),
  fatality_count INT64 OPTIONS(description="Number of fatalities that resulted from the storm"),
  property_loss STRING OPTIONS(description="Estimated property loss in USD. Note that zero does not indicate $0. Possible values are: 0 - unknown or not provided; 1 - <50; 2 - 50 - <500; 3 - 500 - <5,000; 4 - 5,000 - <50,000; 5 - 50,000 - <500,000; 6 - 500,000 - <5,000,000; 7 - 5,000,000 - <50,000,000; 8 - 50,000,000 - <500,000,000; 9 - 500,000,000 or greater."),
  crop_loss STRING OPTIONS(description="Estimated crop value loss in millions of USD. Note that zero does not indicate $0. This data was is available starting in 2007"),
  yearly_tornado_count STRING OPTIONS(description="Count of tornadoes that year after the given tornado is reported to the NWS database. This does not necessarily indicate sequential order because of reporting potential delays."),
  start_lon FLOAT64 OPTIONS(description="Tornado's starting longitude in decimal degrees"),
  start_lat FLOAT64 OPTIONS(description="Tornado's starting latitude in decimal degrees"),
  end_long FLOAT64 OPTIONS(description="Tornado's end longitude in decimal degrees"),
  end_lat FLOAT64 OPTIONS(description="Tornado's end latitude in decimal degrees"),
  length FLOAT64 OPTIONS(description="Length of the tornado, in miles"),
  width FLOAT64 OPTIONS(description="Width of the tornado in feet"),
  tornado_path_geom GEOGRAPHY OPTIONS(description="Geographic representation of the storm's path")
)
PARTITION BY DATE(_PARTITIONTIME)
CLUSTER BY state_fips_code, magnitude, tornado_path_geom;

INSERT INTO `bigquery-public-data.noaa_historic_severe_storms.tornado_paths` (storm_date, storm_time, time_zone_offset, state_abbreviation, state_name, state_fips_code, magnitude, injured_count, fatality_count, property_loss, crop_loss, yearly_tornado_count, start_lon, start_lat, end_long, end_lat, length, width, tornado_path_geom, _PARTITIONTIME) VALUES ('2017-03-06', '19:47:00', '-06:00', 'IA', 'Iowa', '19', '0', 0, 0, '25000', '0', '614739', -92.9974, 41.4611, -92.9041, 41.4976, 5.45, 195.0, 'LINESTRING(-92.9974 41.4611, -92.9041 41.4976)', NULL), ('1999-04-08', '16:13:00', '-06:00', 'IA', 'Iowa', '19', '2', 0, 0, '0.12', '0', '816', -93.75, 41.18, -93.45, 41.58, 32.0, 0.0, 'LINESTRING(-93.75 41.18, -93.675 41.28, -93.6 41.38, -93.525 41.48, -93.45 41.58)', NULL), ('2007-06-22', '15:35:00', '-06:00', 'IA', 'Iowa', '19', '2', 0, 0, '0.7', '0.015', '770', -93.78, 41.49, -93.66, 41.47, 6.36, 450.0, 'LINESTRING(-93.78 41.49, -93.66 41.47)', NULL), ('2012-04-14', '20:22:00', '-06:00', 'IA', 'Iowa', '19', '1', 0, 0, '0.075', '0', '365283', -92.5092, 41.2498, -92.4847, 41.2493, 1.27, 270.0, 'LINESTRING(-92.5092 41.2498, -92.4847 41.2493)', NULL), ('2007-06-01', '11:07:00', '-06:00', 'IA', 'Iowa', '19', '3', 7, 0, '16', '0', '664', -91.19, 41.27, -91.03, 41.46, 15.75, 2322.0, 'LINESTRING(-91.19 41.27, -91.11 41.365, -91.03 41.46)', NULL);