Consider the following three tables, primary and foreign keys. Table Name SalesP
ID: 3590976 • Letter: C
Question
Consider the following three tables, primary and foreign keys.
Table Name SalesPeople
Attribute Name Type Key Type
EmployeeNumber Number Primary Key
Name Character
JobTitle Character
Address Character
PhoneNumber Character
YearsInPosition Number
Table Name ProductDescription
Attribute Name Type Key Type
ProductNumber Number Primary Key
ProductName Character
ProductPrice Number
Table Name SalesOrder
Attribute Name Type Key Type
SalesOrderNumber Number Primary Key
ProductNumber Number Foreign Key
EmployeeNumber Number Foreign Key
SalesOrderDate Date
Assume that you draw up a new sales order for each product sold.
Develop the following queries and submit them as a picture or document:
a. All the Sales People with less than three years in position who have sold Product Number 1167. (3 pts)
b. All the Products with the word “bracket” in the Product Name. (3 pts)
c. All the Sales Orders for products with a price of more than $33. (3 pts)
Explanation / Answer
Queries
a. All the Sales People with less than three years in position who have sold Product Number 1167.
select Name
from SalesPeople
inner join ProductDescription on ProductDescription.ProductNumber = SalesOrder.ProductNumber
inner join SalesOrder on SalesOrder.EmployeeNumber = SalesPeople.EmployeeNumber
where YearsInPosition < 3 and SalesOrder.ProductNumber = 1167;
b. All the Products with the word “bracket” in the Product Name.
select ProductNumber, ProductName from ProductDescription where ProductName like '%bracket%';
c. All the Sales Orders for products with a price of more than $33.
select SalesOrderNumber, ProductName, ProductPrice
from ProductDescription
inner join SalesOrder on ProductDescription.ProductNumber = SalesORder.ProductNumber
inner join SalesPeople on SalesOrder.EmployeeNumber = SalesPeople.EmployeeNumber
where ProductPrice > 33;