Question: 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
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
Figure : ConstructCo Database
Given the structure and contents of the ConstructCo database shown in Figure use
SQL commands to answer following exercises
a Download the following file from Moodle: Week : ConstructCoMySQLtxt
b Import the file ConstructCoMySQLtxt into XAMPP.
c 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.
d Having created the table structure in c write the SQL code to enter the first two rows
for the table shown in Figure Each row should be inserted individually, without using a
subquery. Insert the rows in the order that they are listed in the figure.
Figure
The EMP Table
e 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 sub query should
only retrieve the columns needed for the EMP table and only the employees shown in
the figure.
f Write the SQL code to change the job code to for the person whose employee
number EMPNUM is
g 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.
h Write the SQL code to create a copy of EMP including all of its data, and naming the
copy EMP
i 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:
EMPPCT NUMBER
PROJNUM CHAR
Note: If your SQL implementation requires it you may use DECIMAL or
NUMERIC rather than NUMBER
j Using the EMP table, write the SQL code to change the EMPPCT value to for the
person whose employee number EMPNUM is
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
