diff --git a/hows-the-weather/data/Tables/airquality.sql b/hows-the-weather/data/Tables/airquality.sql new file mode 100644 index 0000000..3d4dc77 --- /dev/null +++ b/hows-the-weather/data/Tables/airquality.sql @@ -0,0 +1,16 @@ +CREATE TABLE [data].[AirQuality]( + [location_id] [int] NOT NULL, + [report_date] [date] NOT NULL, + [air_quality_index] [float](24) NOT NULL, + [dominant_pollutant] [varchar](10) NOT NULL, + [generated_on] [datetime] NOT NULL, + + INDEX [ix_location_id] NONCLUSTERED ([location_id]), + CONSTRAINT [fk_aq_location_id] FOREIGN KEY ([location_id]) REFERENCES [data].[Location](location_id), + + PRIMARY KEY CLUSTERED + ( + [report_date] ASC, + [location_id] ASC + ) +); \ No newline at end of file diff --git a/hows-the-weather/data/Tables/location.sql b/hows-the-weather/data/Tables/location.sql new file mode 100644 index 0000000..7760d0d --- /dev/null +++ b/hows-the-weather/data/Tables/location.sql @@ -0,0 +1,16 @@ +CREATE TABLE [data].[Location]( + [city_name] [varchar](255) NOT NULL, + [state_code] [varchar](2) NOT NULL, + [country_code] [varchar](2) NOT NULL, + [lat] [float](24) NOT NULL, + [lon] [float](24) NOT NULL, + [location_id] [int] IDENTITY(1,1) NOT NULL, + + INDEX [ix_location_id] NONCLUSTERED ([location_id]), + CONSTRAINT [ix_location] UNIQUE ([city_name], [state_code], [country_code]), + + PRIMARY KEY CLUSTERED + ( + [location_id] ASC + ) +); \ No newline at end of file diff --git a/hows-the-weather/data/Tables/moon.sql b/hows-the-weather/data/Tables/moon.sql new file mode 100644 index 0000000..770d27b --- /dev/null +++ b/hows-the-weather/data/Tables/moon.sql @@ -0,0 +1,22 @@ +CREATE TABLE [data].[Moon]( + [report_date] [date] NOT NULL, + [moonrise_ts] [datetime] NULL, + [moonrise_az] [float](24) NULL, + [moonset_ts] [datetime] NULL, + [moonset_az] [float](24) NULL, + [high_moon_ts] [datetime] NULL, + [high_moon_dce] [float](24) NULL, + [moonphase_deg] [float](24) NOT NULL, + [moonphase_desc] [varchar](20) NOT NULL, + [location_id] [int] NOT NULL, + [generated_on] [datetime] NOT NULL, + + INDEX [ix_location_id] NONCLUSTERED ([location_id]), + CONSTRAINT [fk__mn_location_id] FOREIGN KEY ([location_id]) REFERENCES [data].[Location](location_id), + + PRIMARY KEY CLUSTERED + ( + [report_date] ASC, + [location_id] ASC + ) +); \ No newline at end of file diff --git a/hows-the-weather/data/Tables/weather.sql b/hows-the-weather/data/Tables/weather.sql new file mode 100644 index 0000000..f565824 --- /dev/null +++ b/hows-the-weather/data/Tables/weather.sql @@ -0,0 +1,18 @@ +CREATE TABLE [data].[Weather] +( + [report_date] [date] NOT NULL, + [location_id] [int] NOT NULL, + [temperature] [float](24) NOT NULL, + [wind_speed] [float](24) NOT NULL, + [humidity] [float](24) NOT NULL, + [generated_on] [datetime] NOT NULL, + + INDEX [ix_location_id] NONCLUSTERED ([location_id]), + CONSTRAINT [fk_wt_location_id] FOREIGN KEY ([location_id]) REFERENCES [data].[Location](location_id), + + PRIMARY KEY CLUSTERED + ( + [report_date] ASC, + [location_id] ASC + ) +); \ No newline at end of file diff --git a/hows-the-weather/data/airquality.sql b/hows-the-weather/data/airquality.sql deleted file mode 100644 index 455056d..0000000 --- a/hows-the-weather/data/airquality.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE [data].[AirQuality]( - [city_name] [varchar](255) NOT NULL, - [state_code] [varchar](2) NOT NULL, - [country_code] [varchar](2) NOT NULL, - [lat] [float](24) NULL, - [lon] [float](24) NULL, - [report_date] [date] NOT NULL, - [air_quality_index] [float](24) NOT NULL, - [dominant_pollutant] [varchar](10) NOT NULL, - [generated_on] [datetime] NOT NULL, - - PRIMARY KEY CLUSTERED - ( - [city_name] ASC, - [state_code] ASC, - [country_code] ASC, - [report_date] ASC - ) -); \ No newline at end of file diff --git a/hows-the-weather/data/moon.sql b/hows-the-weather/data/moon.sql deleted file mode 100644 index dc017d4..0000000 --- a/hows-the-weather/data/moon.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE [data].[Moon]( - [report_date] [date] NOT NULL, - [moonrise_ts] [datetime] NULL, - [moonrise_az] [float](24) NULL, - [moonset_ts] [datetime] NULL, - [moonset_az] [float](24) NULL, - [high_moon_ts] [datetime] NULL, - [high_moon_dce] [float](24) NULL, - [moonphase_deg] [float](24) NOT NULL, - [moonphase_desc] [varchar](20) NOT NULL, - [city_name] [varchar](255) NOT NULL, - [state_code] [varchar](2) NOT NULL, - [country_code] [varchar](2) NOT NULL, - [lat] [float](24) NOT NULL, - [lon] [float](24) NOT NULL, - [generated_on] [datetime] NOT NULL -); \ No newline at end of file diff --git a/hows-the-weather/data/weather.sql b/hows-the-weather/data/weather.sql deleted file mode 100644 index 8396d59..0000000 --- a/hows-the-weather/data/weather.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE [data].[Weather] -( - [city_name] [varchar](255) NOT NULL, - [state_code] [varchar](2) NOT NULL, - [country_code] [varchar](2) NOT NULL, - [lat] [float](24) NULL, - [lon] [float](24) NULL, - [report_date] [date] NOT NULL, - [temperature] [float](24) NOT NULL, - [wind_speed] [float](24) NOT NULL, - [humidity] [float](24) NOT NULL, - [generated_on] [datetime] NOT NULL, - - PRIMARY KEY CLUSTERED - ( - [city_name] ASC, - [state_code] ASC, - [country_code] ASC, - [report_date] ASC - ) -); \ No newline at end of file