Question
Using MySQL syntax create and run the following SQL scripts for the problems listed below within the sales_co schema. A script needed to create the
Using MySQL syntax create and run the following SQL scripts for the problems listed below within the sales_co schema. A script needed to create the sales_co schema can be found on D2L named Sales_Company in the SQL Scripts content section. Submit the SQL you used to answer each question via the D2L Assignment folder as a text or Word document. On the next page is an ERD of the sales_co schema for your reference.
Create a new table called SALEREP. The table structure should contain the following columns and constraints:
Column Name | Data type | Constraint |
id | Numeric | Primary Key |
first_name | Character | Not null |
last_name | Character | Not null |
Insert three new records into the SALEREP table with the following values:
id | first_name | last_name |
12345 | Don | Klingel |
67890 |
|
|
99999 | Dummys | Record |
FNote: The text within the should be replaced with your actual first and last name.
Modify the existing CUSTOMER table to include a new column called salerep_id and make it a foreign key referencing the appropriate column in the new SALEREP table.
Update the salerep_id column in the CUSTOMER table to a value of 12345 when the customers areacode is equal to 615 otherwise set the column value to 67890. DO NOT USE A CASE OR IF CLAUSE. (Hint: You might need to use more than one SQL statement.)
Remove from the SALEREP table any record with a first name equal to Dummys and a last name equal to Record. (Hint: Your SQL statement should use the first_name and last_name columns.)
id INT (11) last-name VARCHAR(15) frst- am e VARCHAR( 15) inital CHARCA) areacode AR(3) invoice id INT (11) customer_d NT(11) date shipped DATE mice.id INT() Iine number INT (11) product code VARCHAR(0) unit, INT(11) price DECIMAL (9,2) phone ARIB) Obalance DECIMAL(9,2) product t code VAROHAR(0) vendor id INT (11) name VARCHAR(3S) contact VARCHAR(1) description VARCHAR(3S) dat.ch ged DATE quantity DT(11) minimum quanbty INT (11) areacode 3) -- phone CHAR(B) state CMAR(2) price DECIMAL (3,2) discount DECMAL (5,2) vendor-'d INT(11) order-tag TDVYNT( 1) id INT (11) last-name VARCHAR(15) frst- am e VARCHAR( 15) inital CHARCA) areacode AR(3) invoice id INT (11) customer_d NT(11) date shipped DATE mice.id INT() Iine number INT (11) product code VARCHAR(0) unit, INT(11) price DECIMAL (9,2) phone ARIB) Obalance DECIMAL(9,2) product t code VAROHAR(0) vendor id INT (11) name VARCHAR(3S) contact VARCHAR(1) description VARCHAR(3S) dat.ch ged DATE quantity DT(11) minimum quanbty INT (11) areacode 3) -- phone CHAR(B) state CMAR(2) price DECIMAL (3,2) discount DECMAL (5,2) vendor-'d INT(11) order-tag TDVYNT( 1)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started