Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. The ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee
4. The ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee works on each project. The structure and contents of the ConstructCo database are shown in Figure 1. Figure 1: ConstructCo Database Relational diagram Table name: EMPLOYEE Database name: Ch08_Constructe Table name: JOB Tahle name. ASCICNMFNT Table name: PROJECT Given the structure and contents of the ConstructCo database shown in Figure 1, use SQL commands to answer following exercises a. Download the following file from Moodle: Week 8: 08_ConstructCo_MySQL.txt b. Import the file 08_ConstructCo_MySQL.txt into XAMPP. c. Write the SQL code that will create only the table structure for a table named EMP_1. This table will be a subset of the EMPLOYEE table. The basic EMP_1 table structure is summarized in the following table. Use EMP_NUM as the primary key. Note that the JOB_CODE is the FK to JOB so be certain to enforce referential integrity. Your code should also prevent null entries in EMP_LNAME and EMP_FNAME. d. Having created the table structure in 4 (c), write the SQL code to enter the first two rows for the table shown in Figure 2. Each row should be inserted individually, without using a subquery. Insert the rows in the order that they are listed in the figure. Figure 2 The EMP_1 Table e. Using the EMPLOYEE table that already exists, use a subquery to insert the remaining rows from the EMPLOYEE table into the EMP_1 table. Remember, your sub- query should only retrieve the columns needed for the EMP_1 table and only the employees shown in the figure. f. Write the SQL code to change the job code to 501 for the person whose employee number (EMP_NUM) is 107. g. Write the SQL code to delete the row for William Smithfield, who was hired on June 22, 2004, and whose job code is 500 . (Hint: Use logical operators to include all of the information given in this problem.) h. Write the SQL code to create a copy of EMP_1, including all of its data, and naming the copy EMP_2. i. Using the EMP_2 table, write the SQL code that will add the attributes EMP_PCT and PROJ_NUM to EMP_2. The EMP_PCT is the bonus percentage to be paid to each employee. The new attribute characteristics are: \[ \begin{array}{ll} \text { EMP_PCT } & \text { NUMBER(4,2) } \\ \text { PROJ_NUM } & \text { CHAR(3) } \end{array} \] Note: If your SQL implementation requires it, you may use DECIMAL(4,2) or NUMERIC(4,2) rather than NUMBER(4,2). j. Using the EMP_2 table, write the SQL code to change the EMP_PCT value to 3.85 for the person whose employee number (EMP_NUM) is 103
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