-- DBMS: bigquery
CREATE TABLE `bigquery-public-data.noaa_historic_severe_storms.storms_2020`
(
  episode_id STRING OPTIONS(description="ID assigned by NWS to denote the storm episode; links the event details file with the information within location file"),
  event_id STRING OPTIONS(description="ID assigned by NWS to note a single, small part that goes into a specific storm episode; links the storm episode between the three files downloaded from SPC’s website"),
  state STRING OPTIONS(description="The full text state name where the event occurred"),
  state_fips_code STRING OPTIONS(description="Unique FIPS code identifier assigned to each state. State names and their corresponding FIPS codes are available as a BigQuery Public Dataset: bigquery-public-data.census_fips_codes.states_2016  The geographic polygons that define the perimeter of each state are available as a BigQuery Public Dataset: bigquery-public-data.geo_us_boundaries.us_states"),
  event_type STRING OPTIONS(description="The only events permitted in Storm Data are listed in Table 1 of Section 2.1.1 of NWS Directive 10-1605 at http://www.nws.noaa.gov/directives/sym/pd01016005curr.pdf. The chosen event type is the one that most accurately describes the meteorological event leading to fatalities, injuries, damage, etc. However, significant events, such as tornadoes, having no impact or causing no damage, are also included in Storm Data."),
  cz_type STRING OPTIONS(description="Indicates whether the event happened in   - C: County/Parish  - Z: NWS zone  - M: Marine"),
  cz_fips_code STRING OPTIONS(description="Unique FIPS code identifier assigned to each county.   State names and their corresponding FIPS codes are available as a BigQuery Public Dataset: bigquery-public-data.census_fips_codes.counties_2016  The geographic polygons that define the perimeter of each state are available as a BigQuery Public Dataset: bigquery-public-data.geo_us_boundaries.us_counties"),
  cz_name STRING OPTIONS(description="(County/Parish, Zone or Marine Name assigned to the county FIPS number or NWS Forecast Zone  NWS Forecast Zones are available as a BigQuery Public Dataset: bigquery-public-data.noaa_historic_severe_storms.nws_forecast_zones"),
  wfo STRING OPTIONS(description="National Weather Service Forecast Office’s area of responsibility (County Warning Area) in which the event occurred"),
  event_begin_time DATETIME OPTIONS(description="The date and time that the event began. Note that episodes and events may have different start and end times if multiple events occured in the same episode"),
  event_timezone STRING OPTIONS(description="The time zone in which the event_begin_time and the event_end_time is recorded."),
  event_end_time DATETIME OPTIONS(description="The date and time that the event ended. Note that episodes and events may have different start and end times if multiple events occured in the same episode"),
  injuries_direct INT64 OPTIONS(description="The number of injuries directly related to the weather event"),
  injuries_indirect INT64 OPTIONS(description="The number of injuries indirectly related to the weather event"),
  deaths_direct INT64 OPTIONS(description="The number of deathes directly related to the weather event"),
  deaths_indirect INT64 OPTIONS(description="The number of deathes indirectly related to the weather event"),
  damage_property INT64 OPTIONS(description="The estimated amount of damage to property incurred by the weather event, in USD at the time of the event. Values are not adjusted for inflation  Note: Values listed as 0 do not necessarily mean that no property damage occurred as a result of the event"),
  damage_crops INT64 OPTIONS(description="The estimated amount of damage to crops incurred by the weather event, in USD at the time of the storm. Values are not adjusted for inflation  Note: Values listed as 0 do not necessarily mean that no property damage occurred as a result of the event"),
  source STRING OPTIONS(description="Source reporting the weather event  Note: This can be any entry. Values are not restricted to specific categories"),
  magnitude FLOAT64 OPTIONS(description="Measured extent of the magnitude type. This is only used for wind speeds and hail size. Wind speeds are in MPH; Hail sizes are in inches"),
  magnitude_type STRING OPTIONS(description="Differentiates between the type of mangitude measured. - EG = Wind Estimated Gust  - ES = Estimated Sustained Wind  - MS = Measured Sustained Wind  - MG = Measured Wind Gust  No magnitude type is included for hail"),
  flood_cause STRING OPTIONS(description="Reported or estimated cause of the flood"),
  tor_f_scale STRING OPTIONS(description="Enhanced Fujita Scale describes the strength of the tornado based on the amount and type of damage caused by the tornado. The F-scale of damage will vary in the destruction area; therefore, the highest value of the F-scale is recorded for each event.    - EF0 – Light Damage (40 – 72 mph)   - EF1 – Moderate Damage (73 – 112 mph)   - EF2 – Significant damage (113 – 157 mph)   - EF3 – Severe Damage (158 – 206 mph)   - EF4 – Devastating Damage (207 – 260 mph)   - EF5 – Incredible Damage (261 – 318 mph)"),
  tor_length STRING OPTIONS(description="Length of the tornado or tornado segment while on the ground (minimal of tenths of miles)"),
  tor_width STRING OPTIONS(description="Width of the tornado or tornado segment while on the ground (in feet)"),
  tor_other_wfo STRING OPTIONS(description="Indicates the continuation of a tornado segment as it crossed from one National Weather Service Forecast Office to another. The subsequent WFO identifier is provided within this field."),
  location_index STRING OPTIONS(description="Number assigned by NWS to specific locations within the same Storm event. Each event’s sequentially increasing location index number will have a corresponding lat/lon point"),
  event_range FLOAT64 OPTIONS(description="A hydro-meteorological event will be referenced, minimally, to the nearest tenth of a mile, to the geographical center (not from the village/city boundaries or limits) of a particular village/city, airport, or inland lake, providing that the reference point is documented in the Storm Data software location database."),
  event_azimuth STRING OPTIONS(description="16-point compass direction from a particular village/city, airport, or inland lake, providing that the reference point is documented in the Storm Data software location database of > 130,000 locations."),
  reference_location STRING OPTIONS(description="Reference location of the center from which the range is calculated and the azimuth is determined"),
  event_latitude FLOAT64 OPTIONS(description="The latitude where the event occurred (rounded to the hundredths in decimal degrees; includes an ‘-‘ if it’s S of the Equator)"),
  event_longitude FLOAT64 OPTIONS(description="The longitude where the event occurred (rounded to the hundredths in decimal degrees; includes an ‘-‘ if it’s W of the Prime Meridian)"),
  event_point GEOGRAPHY OPTIONS(description="Geographic representation of the event_longitude and latitude")
)
PARTITION BY DATE(_PARTITIONTIME)
CLUSTER BY event_type, state_fips_code, state;

INSERT INTO `bigquery-public-data.noaa_historic_severe_storms.storms_2020` (episode_id, event_id, state, state_fips_code, event_type, cz_type, cz_fips_code, cz_name, wfo, event_begin_time, event_timezone, event_end_time, injuries_direct, injuries_indirect, deaths_direct, deaths_indirect, damage_property, damage_crops, source, magnitude, magnitude_type, flood_cause, tor_f_scale, tor_length, tor_width, tor_other_wfo, location_index, event_range, event_azimuth, reference_location, event_latitude, event_longitude, event_point, _PARTITIONTIME) VALUES ('145013', '870783', 'Ca', '6', 'astronomical low tide', 'Z', '106', 'SOUTHERN HUMBOLDT INTERIOR', 'EKA', '2020-01-15 22:00:00', 'PST-8', '2020-01-16 15:00:00', 0, 0, 0, 0, 0, 0, 'Public', nan, NULL, 'nan', NULL, NULL, NULL, NULL, NULL, nan, NULL, NULL, nan, nan, NULL, NULL), ('152460', '918488', 'Ne', '33', 'astronomical low tide', 'Z', '7', 'SULLIVAN', 'GYX', '2020-08-04 12:00:00', 'EST-5', '2020-08-05 22:28:00', 0, 0, 0, 0, 0, 0, 'Law Enforcement', nan, NULL, 'nan', NULL, NULL, NULL, NULL, NULL, nan, NULL, NULL, nan, nan, NULL, NULL), ('152770', '920227', 'Te', '48', 'astronomical low tide', 'Z', '436', 'MATAGORDA ISLANDS', 'HGX', '2020-09-21 00:00:00', 'CST-6', '2020-09-23 23:59:00', 0, 0, 0, 0, 0, 0, 'Emergency Manager', nan, NULL, 'nan', NULL, NULL, NULL, NULL, NULL, nan, NULL, NULL, nan, nan, NULL, NULL), ('153056', '921718', 'Fl', '12', 'astronomical low tide', 'Z', '125', 'COASTAL DUVAL', 'JAX', '2020-09-21 13:30:00', 'EST-5', '2020-09-21 14:15:00', 0, 0, 0, 0, 0, 0, 'NWS Storm Survey', nan, NULL, 'nan', NULL, NULL, NULL, NULL, NULL, nan, NULL, NULL, nan, nan, NULL, NULL), ('153192', '922414', 'Ma', '23', 'astronomical low tide', 'Z', '24', 'COASTAL CUMBERLAND', 'GYX', '2020-09-22 14:45:00', 'EST-5', '2020-09-22 16:12:00', 0, 0, 0, 0, 5000, 0, 'Emergency Manager', nan, NULL, 'nan', NULL, NULL, NULL, NULL, NULL, nan, NULL, NULL, nan, nan, NULL, NULL);