Create the following table in your database with the following schema: Table: salesPerson | Column Name 1 Туре | sales_id | name | salary | commission_rate | int | hire_date | int | varchar | | int | date +--- sales_id is the primary key column for this table. Each row of this table indicates the name and the ID of a salesperson alongside their salary, commission rate, and hire date. CO Table: Company | Column Name | Type | int | varchar | | varchar | | com_id I name | city +-- ----+ com_id is the primary key column for this table. Each row of this table indicates the name and the ID of a company and the city in which the company is located. Table: Orders | Column Name | Type I | order_id I order date I com_id | sales_id | int | date | | int | int | int | amount +-- +------+ order_id is the primary key column for this table. com_id is a foreign key to com_id from the Company table. sales_id is a foreign key to com_id from the SalesPerson table. Each row of this table contains information about one order. This includes the ID of the company, the ID of the salesperson, the date of the order, and the amount paid. Add the following data to your tables:

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
icon
Related questions
icon
Concept explainers
Question

Create the tables in sql code of the attached question ?

Create the following table in your database with the following schema:
Table: SalesPerson
| Column Name
| Туре
+---
| sales id
| int
| varchar |
| int
I name
| salary
| commission_rate | int
| hire_date
I date
+----
----+
sales_id is the primary key column
Each row of this table indicates the name and the ID of a salesperson
alongside their salary, commission rate, and hire date.
this table.
Table: Company
| Column Name | Type
| int
| varchar I
| varchar |
| com_id
| name
| city
-----+
com_id is the primary key column for this table.
Each row of this table indicates the name and the ID of a company and the
city in which the company is located.
Table: Orders
| Column Name | Type |
+-
| order id
| order date
| com id
| sales id
| int
| date |
| int
| int
| int
| amount
+----
-----+
order id is the primary key column for this table.
com id is a foreign key to com id from the Company table.
sales id is a foreign key to com id from the SalesPerson table.
Each row of this table contains information about one order. This includes
the ID of the company, the ID of the salesperson, the date of the order, and
the amount paid.
Add the following data to your tables:
Transcribed Image Text:Create the following table in your database with the following schema: Table: SalesPerson | Column Name | Туре +--- | sales id | int | varchar | | int I name | salary | commission_rate | int | hire_date I date +---- ----+ sales_id is the primary key column Each row of this table indicates the name and the ID of a salesperson alongside their salary, commission rate, and hire date. this table. Table: Company | Column Name | Type | int | varchar I | varchar | | com_id | name | city -----+ com_id is the primary key column for this table. Each row of this table indicates the name and the ID of a company and the city in which the company is located. Table: Orders | Column Name | Type | +- | order id | order date | com id | sales id | int | date | | int | int | int | amount +---- -----+ order id is the primary key column for this table. com id is a foreign key to com id from the Company table. sales id is a foreign key to com id from the SalesPerson table. Each row of this table contains information about one order. This includes the ID of the company, the ID of the salesperson, the date of the order, and the amount paid. Add the following data to your tables:
Input:
SalesPerson table:
+----------
| sales id | name | salary | commission rate | hire date
| 1
| 2
| 3
| 4
| 5
| John | 100000 | 6
| 12000
| Mark | 65000
| 25000
| Alex | 5000
| 5
| 12
| 25
| 10
| 4/1/2006
| 5/1/2010
| 12/25/2008 I
| 1/1/2005
| 2/3/2007
| Amy
| Pam
+---
Company table:
+---
com_id | name
| city
| 1
| 2
| 3
| 4
| RED
| ORANGE | New York |
| YELLOW | Boston
| GREEN
| Boston
| Austin
+--
Orders table:
+---------
| order id | order date | com id | sales id | amount |
+--
-------+
| 1
| 2
| 3
| 4
| 1/1/2014
| 2/1/2014
| 3/1/2014
| 4/1/2014
| 3
| 4
| 1
| 1
| 4
| 5
| 1
| 4
| 10000
| 5000
| 50000
| 25000
Write an SQL query to report the names of all the salespersons who did not have any orders related
to the company with the name "RED".
Return the result table in any order.
The results should be:
Output:
+----
| name |
+------+
| Amy
| Mark |
| Alex |
+------+
Transcribed Image Text:Input: SalesPerson table: +---------- | sales id | name | salary | commission rate | hire date | 1 | 2 | 3 | 4 | 5 | John | 100000 | 6 | 12000 | Mark | 65000 | 25000 | Alex | 5000 | 5 | 12 | 25 | 10 | 4/1/2006 | 5/1/2010 | 12/25/2008 I | 1/1/2005 | 2/3/2007 | Amy | Pam +--- Company table: +--- com_id | name | city | 1 | 2 | 3 | 4 | RED | ORANGE | New York | | YELLOW | Boston | GREEN | Boston | Austin +-- Orders table: +--------- | order id | order date | com id | sales id | amount | +-- -------+ | 1 | 2 | 3 | 4 | 1/1/2014 | 2/1/2014 | 3/1/2014 | 4/1/2014 | 3 | 4 | 1 | 1 | 4 | 5 | 1 | 4 | 10000 | 5000 | 50000 | 25000 Write an SQL query to report the names of all the salespersons who did not have any orders related to the company with the name "RED". Return the result table in any order. The results should be: Output: +---- | name | +------+ | Amy | Mark | | Alex | +------+
Expert Solution
Syntax for table creation:

CREATE TABLE table_name 

column1 data type; 

column2 data type; 

column3 date type; 

... 

);  

Note: For keeping sales_id in orders as the foreign key of com_id in sales_person it is not possible because com_id column is not there in slaes order table it should be sales_Id 

For keeping column as primary key we declare primary after column data type  

For foreign key  we should use FOREIGN KEY (table_name) REFERENCES other_table_name(other_table_column)

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Query Syntax
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
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education