Table name: Supplier Column Name Role Data Type Length Constraint supplierID Stores the ID of a supplier Number 10 Primary key supplierFName Stores the first name of a supplier Varchar2 30 Cannot be null supplierLName Stores the last Name of a supplier Varchar2 30 Cannot be null supplierDOB Stores the date of birth of a supplier Date - supplierNBPro Stores the number of products supplied by a supplier Number 3 Should be greater than 10 a. Write in SQL a statement that adds a new column named comapnyID of type char(5). This column should be defined as a foreign key that relates the table Supplier to the table Company b. Write in SQL a query that displays the ids of the suppliers who supply the highest number of products. c. Create a view named ‘SupplierDetails’ to hold all the details of suppliers whose last names start with ‘bait’ and who supply between 50 and 200 products.
Table name: Supplier |
||||
Column Name |
Role |
Data Type |
Length |
Constraint |
supplierID |
Stores the ID of a supplier |
Number |
10 |
Primary key |
supplierFName |
Stores the first name of a supplier |
Varchar2 |
30 |
Cannot be null |
supplierLName |
Stores the last Name of a supplier |
Varchar2 |
30 |
Cannot be null |
supplierDOB |
Stores the date of birth of a supplier |
Date |
- |
|
supplierNBPro |
Stores the number of products supplied by a supplier |
Number |
3 |
Should be greater than 10 |
a. Write in SQL a statement that adds a new column named comapnyID of type char(5). This column should be defined as a foreign key that relates the table Supplier to the table Company
b. Write in SQL a query that displays the ids of the suppliers who supply the highest number of products.
c. Create a view named ‘SupplierDetails’ to hold all the details of suppliers whose last names start with ‘bait’ and who supply between 50 and 200 products.
Step by step
Solved in 3 steps