Create the following tables in your database with the following schema: Table: Countries | Column Name | Туре | country_id I country_name +---- | int | varcharI -----+---------+ country_id is the primary key for this table. Each row of this table contains the ID and the name of one country. Table: Weather ------ | Column Name 1 Туре I ---- I country_id | weather state | int I day | int | date | +- +------+ (country_id, day) is the primary key for this table. Each row of this table indicates the weather state in a country for one day. Add the following data to your tables: Input: Countries table: +------------ I country_id | country_name | | USA | Australia | Peru I China | Morocco | Spain | 2 Weather table: +---------- | country_id | weather_state | day | 2019-11-01 | | 2019-10-28 | | 2019-10-27 | | 2019-11-10 | | 2019-11-11 | | 2019-11-12 | | 2019-11-07 I | 2019-11-09 | | 2019-11-23 | | 2019-11-28 | | 2019-12-01 | | 2019-12-02 | | 2019-11-05 | | 2019-11-15 | | 2019-11-25 | | 2019-10-23 | | 2019-12-23 | | 2 | 2 | 2 | 15 | 12 | 12 | -2 | 3 | 16 | 18 | 21 | 25 | 22 | 20 | 25 | 27 | 31 | 7 1 3
Create the following tables in your database with the following schema: Table: Countries | Column Name | Туре | country_id I country_name +---- | int | varcharI -----+---------+ country_id is the primary key for this table. Each row of this table contains the ID and the name of one country. Table: Weather ------ | Column Name 1 Туре I ---- I country_id | weather state | int I day | int | date | +- +------+ (country_id, day) is the primary key for this table. Each row of this table indicates the weather state in a country for one day. Add the following data to your tables: Input: Countries table: +------------ I country_id | country_name | | USA | Australia | Peru I China | Morocco | Spain | 2 Weather table: +---------- | country_id | weather_state | day | 2019-11-01 | | 2019-10-28 | | 2019-10-27 | | 2019-11-10 | | 2019-11-11 | | 2019-11-12 | | 2019-11-07 I | 2019-11-09 | | 2019-11-23 | | 2019-11-28 | | 2019-12-01 | | 2019-12-02 | | 2019-11-05 | | 2019-11-15 | | 2019-11-25 | | 2019-10-23 | | 2019-12-23 | | 2 | 2 | 2 | 15 | 12 | 12 | -2 | 3 | 16 | 18 | 21 | 25 | 22 | 20 | 25 | 27 | 31 | 7 1 3
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
code of create table and insert table only please

Transcribed Image Text:Create the following tables in your database with the following schema:
Table: Countries
+-
| Column Name
Туре
| country_id
| country_name
| int
| varcharI
-------+
country_id is the primary key for this table.
Each row of this table contains the ID and the name of one country.
Table: Weather
+-----
| Column Name
| Type |
country_id
| weather state
| day
| int
int
| date |
+-
+------+
(country_id,
Each row of this table indicates the weather state in a country for one day.
day) is the primary key for this table.
Add the following data to your tables:
Input:
Countries table:
+-
-----
| country_id | country_name |
+
| 2
| 3
| USA
| Australia
| Peru
I China
| Morocco
| Spain
| 5
+-
Weather table:
+--
| country_id | weather_state | day
| 2
| 2
| 2
| 3
| 3
| 3
| 5
| 5
| 5
| 7
| 7
| 3
| 16
| 18
| 21
| 25
| 22
| 20
| 25
| 27
| 31
| 15
| 12
| 12
| -2
| 2019-11-07 |
| 2019-11-09 I
| 2019-11-23 |
| 2019-11-28
| 2019-12-01 |
| 2019-12-02 |
| 2019-11-05 |
| 2019-11-15 |
| 2019-11-25 |
| 2019-10-23 |
| 2019-11-01
| 2019-10-28
| 2019-10-27
| 2019-11-10 |
| 2019-11-11
| 2019-11-12
| 8
| 9
| 3
2019-12-23

Transcribed Image Text:Write an SQL query to find the type of weather in each country for November 2019.
The type of weather is:
• Cold if the average weather_state is less than or equal 15,
• Hot if the average weather_state is greater than or equal to 25, and
• Warm otherwise.
Return result table in any order.
The results should be:
Output:
+-
I country_name | weather_type
| USA
| Australia
| Peru
| Morocco
| China
| Cold
I Cold
| Hot
| Hot
I Warm
Explanation:
Average weather_state in USA in November is (15) /1= 15 so weather type is Cold.
Average weather_state in Austraila in November is (-2 + 0 + 3) /3 = 0.333 so weather type is Cold.
Average weather_state in Peru in November is (25) / 1 = 25 so the weather type is Hot.
Average weather_state in China in November is (16 + 18 + 21)/3 = 18.333 so weather type is Warm.
Average weather_state in Morocco in November is (25 + 27+31)/3 = 27.667 so weather type is Hot.
We know nothing about the average weather_state in Spain in November so we do not include it in
the result table.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education