Question: Create and submit a sql script to answer all the questions. Make sure to add comments in the document to add title for each question.
Create and submit a sql script to answer all the questions. Make sure to add comments in the document to add title for each question. Use Chapter database script to create your database that you can use to test your script: ChConstructCoMySQLsql and ChSaleCoMySQLsql Write the SQL code that will create only the table structure for a table named EMP This table will be a subset of the EMPLOYEE table. The basic EMP table structure is summarized in the following table. Use EMPNUM as the primary key. Note that the JOBCODE is the FK to JOB so be certain to enforce referential integrity. Your code should also prevent null entries in EMPLNAME and EMPFNAME. Having created the table structure in Problem write the SQL code to enter the first two rows for the table shown in Figure P Each row should be inserted individually, without using a subquery. Insert the rows in the order that they are listed in the figure. Using the EMPLOYEE table that already exists, use a subquery to insert the remaining rows from the EMPLOYEE table into the EMP table. Remember, your subquery should only retrieve the columns needed for the EMP table and only the employees shown in the figure. Write the SQL code that will save the changes made to the EMP table if supported by your DBMS Write the SQL code to change the job code to for the person whose employee number EMPNUM is Write the SQL code to delete the row for William Smithfield, who was hired on June and whose job code is Hint: Use logical operators to include all of the information given in this problem. Remember, if you are using MySQL you will have to first disable "safe Mode, Write the SQL code to create a copy of EMP including all of its data, and naming the copy EMP Using the EMP table, write the SQL code that will add the attributes EMPPCT and PROJNUM to EMP The EMPPCT is the bonus percentage to be paid to each employee. The new attribute characteristics are: EMP DECIMAL PROJNUM CHAR Using the EMP table, write the SQL code to change the EMPPCT value to for the person whose employee number EMPNUM is Using the EMP table, write a single SQL command to change the EMPPCT value to for the people with employee numbers and Use the following table to answer the remaining questions. Create a trigger named trglinetotal to write the LINETOTAL value in the LINE table every time you add a new LINE row. The LINETOTAL value is the product of the LINEUNITS and LINEPRICE values. Create a trigger named trg lineprod that automatically updates the quantity on hand for each product sold after a new LINE row is added. Create a stored procedure named preinv amounts to update the INVSUBTOTAL, INVTAX, and INVTOTAL. The procedure takes the invoice number as a parameter. The INVSUBTOTAL is the sum of the LINETOTAL amounts for the invoice, the INVTAX is the product of the INVSUBTOTAL and the tax rate percent and the INVTOTAL is the sum of the INVSUBTOTAL and the INVTAX. Create a procedure named precusbalanceupdate that will take the invoice number as a parameter and update the customer balance. Hint: You can use DECLARE to define a TOTINV numeric variable that holds the computed invoice total.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
