Question

The Ch07_ConstructCo database stores data for a consultingcompany that tracks all charges to projects. The...

The Ch07_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 Ch07_ConstructCo database are shown in Figure P7.1.

Note that the ASSIGNMENT table in Figure P7.1 stores the JOB_CHG_HOUR values as an attribute (ASSIGN_CHG_HR) to maintain historical accuracy of the data. The JOB_CHG_HOUR values are likely to change over time. In fact, a JOB_CHG_ HOUR change will be reflected in the ASSIGNMENT table. Naturally, the employee primary job assignment might also change, so the ASSIGN_JOB is also stored. Because those attributes are required to maintain the historical accuracy of the data, they are not redundant.

Given the structure and contents of the Ch07_ConstructCo database shown in Figure P7.1, use SQL commands to answer the following problems.

1. Write the SQL code required to list the employee number, last name, first name, and middle initial of all employees whose last names start with Smith. In other words, the rows for both Smith and Smithfield should be included in the listing. Sort the results by employee number. Assume case sensitivity.

2. Using the EMPLOYEE, JOB, and PROJECT tables in the Ch07_ConstructCo database, write the SQL code that will join the EMPLOYEE and PROJECT tables using EMP_NUM as the common attribute. Display the attributes shown in the results presented in Figure P7.2, sorted by project value.3. Write the SQL code that will produce the same information that was shown in Problem 2, but sorted by the employee's last name.

4. Write the SQL code that will list only the distinct project numbers in the ASSIGNMENT table, sorted by project number.

5. Write the SQL code to validate the ASSIGN_CHARGE values in the ASSIGNMENT table. Your query should retrieve the assignment number, employee number, project number, the stored assignment charge (ASSIGN_CHARGE), and the calculated assignment charge (calculated by multiplying ASSIGN_CHG_HR by ASSIGN_HOURS). Sort the results by the assignment number.

6. Using the data in the ASSIGNMENT table, write the SQL code that will yield the total number of hours worded for each employee and the total charges stemming from those hours worked, sorted by employee number. The results of running that query are shown in Figure P7.6.

7. Write a query to produce the total number of hours and charges for each of the projects represented in the ASSIGNMENT table, sorted by project number. The output is shown in Figure P7.7.8. Write the SQL code to generate the total hours worked and the total charges made by all employees. The results are shown in Figure P7.8.

1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

1.

Query:

SELECT EMP_NUM,         EMP_LNAME,    EMP_FNAME,   EMP_INITIAL

FROM EMPLOYEE

WHERE EMP_LNAME LIKE 'Smith%';

Output:

2.

Query:

SELECT PROJ_NAME, PROJ_VALUE, PROJ_BALANCE,

EMP_LNAME,EMP_FNAME, EMP_INITIAL, EMPLOYEE.JOB_CODE,

JOB_DESCRIPTION,JOB_CHG_HOUR

FROM PROJECT, EMPLOYEE, JOB

WHERE EMPLOYEE.EMP_NUM = PROJECT.EMP_NUM

AND JOB.JOB_CODE = EMPLOYEE.JOB_CODE

ORDER BY PROJ_VALUE;

Output:

3.

Query:

SELECT PROJ_NAME, PROJ_VALUE, PROJ_BALANCE,

EMP_LNAME,EMP_FNAME, EMP_INITIAL, EMPLOYEE.JOB_CODE,

JOB_DESCRIPTION,JOB_CHG_HOUR

FROM PROJECT, EMPLOYEE, JOB

WHERE EMPLOYEE.EMP_NUM = PROJECT.EMP_NUM

AND JOB.JOB_CODE = EMPLOYEE.JOB_CODE

ORDER BY EMP_LNAME;

Output:

4.

Query:

SELECT distinct PROJ_NUM

from ASSIGNMENT

ORDER BY PROJ_NUM;

Output:

5.

Query:

SELECT ASSIGN_NUM, EMP_NUM, PROJ_NUM, ASSIGN_CHARGE,

ASSIGN_CHG_HR * ASSIGN_HOURS AS CACLUATED_ASSIGN_CHARGE

FROM ASSIGNMENT

ORDER BY ASSIGN_NUM;

Output:

6.

Query:

SELECT ASSIGNMENT.EMP_NUM, EMP_LNAME,

SUM(ASSIGNMENT.ASSIGN_HOURS)AS SumOfASSIGN_HOURS,

SUM(ASSIGNMENT.ASSIGN_CHG_HR*ASSIGNMENT.ASSIGN_HOURS) AS SumOfASSIGN_CHARGE

FROM EMPLOYEE, ASSIGNMENT

WHERE EMPLOYEE.EMP_NUM = ASSIGNMENT.EMP_NUM

GROUP BY ASSIGNMENT.EMP_NUM, EMP_LNAME

ORDER BY ASSIGNMENT.EMP_NUM;

Output:

7.

Query:

SELECT PROJ_NUM,

SUM(ASSIGN_HOURS) AS SumOfASSIGN_HOURS,

SUM(ASSIGN_CHARGE) AS SumOfASSIGN_CHARG

FROM ASSIGNMENT

GROUP BY PROJ_NUM

ORDER BY PROJ_NUM;

Output:

Query:

SELECT PROJ_NUM,

SUM(ASSIGN_HOURS) AS SumOfASSIGN_HOURS,

SUM(ASSIGNMENT.ASSIGN_CHG_HR*ASSIGNMENT.ASSIGN_HOURS) AS SumOfASSIGN_CHARGE

FROM ASSIGNMENT

GROUP BY PROJ_NUM

ORDER BY PROJ_NUM;

Output:

8.

Query:

SELECT SUM(ASSIGN_HOURS)AS SumOfASSIGN_HOURS,

SUM(ASSIGN_CHARGE) AS SumOfASSIGN_CHARGE

FROM ASSIGNMENT;

Output:

Add a comment
Know the answer?
Add Answer to:
The Ch07_ConstructCo database stores data for a consultingcompany that tracks all charges to projects. The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • 2) Consider the database schema on the relations (where key attributes have been underlined): PROJECTS(Number, Department,...

    2) Consider the database schema on the relations (where key attributes have been underlined): PROJECTS(Number, Department, ProjectName) EMPLOYEES(Number, Surname, FirstName, Department) ALLOCATIONSEmplovee, Project, Function, Date) NOTE: relation ALLOCATIONS stores the registration number (attribute Employee) of employees that are assigned to a given project (attribute Project is the number of the project, not the name of the project), the function the employee has in that project (i.e., technician, manager, etc.) and the date when the employee has been assigned to that...

  • DROP TABLE EMPLOYEE; DROP TABLE JOB; DROP TABLE EMP; DROP TABLE EMP_1; DROP TABLE EMP_2; CREATE...

    DROP TABLE EMPLOYEE; DROP TABLE JOB; DROP TABLE EMP; DROP TABLE EMP_1; DROP TABLE EMP_2; CREATE TABLE JOB(JOB_CODE CHAR (3) PRIMARY KEY, JOB_DESCRIPTION VARCHAR (20) NOT NULL,JOB_CHG_HOUR NUMBER (5,2) NOT NULL,JOB_LAST_UPDATE DATE NOT NULL); INSERT INTO JOB VALUES('500','Programmer','35.75','20-Nov-2017'); INSERT INTO JOB VALUES('501','System Analyst','96.75','20-Nov-2017'); INSERT INTO JOB VALUES('502','Database Designer','125.00','24-Mar-2018'); CREATE TABLE EMPLOYEE(EMP_NUM CHAR (3) PRIMARY KEY,EMP_LNAME VARCHAR (15) NOT NULL,EMP_FNAME VARCHAR (15) NOT NULL, EMP_INITIAL CHAR (1),EMP_HIREDATE DATE NOT NULL,JOB_CODE CHAR (3), EMP_YEARS NUMBER (2),FOREIGN KEY (JOB_CODE) REFERENCES JOB (JOB_CODE)); INSERT...

  • HELP DATABASE QU Question 1: Think About the relational database table data as given below, write...

    HELP DATABASE QU Question 1: Think About the relational database table data as given below, write the following queries in Oracle SQL. Company (Cid, Cname, City, Budget, Branch) Department (Deptno, Dname, Building, Cname) Employee (Ename, Deptno, Street, City, Phone, Salary) Works (Ename, Deptno, Hire_date) Location (Cname, Location ) 1. Write Query to Create the Company table, suggest appropriate data type of each attribute, consider that there should be a name for each company. 2. Find employee name/names who live in...

  • A state-wide land tax assessment database has two tables: LandParcel that stores a set of land...

    A state-wide land tax assessment database has two tables: LandParcel that stores a set of land parcels, and ZoningTypes that stores a set of zoning codes and zoning types. The LandParcel table has 5 columns: ParcelNumb as text indicating each parcel's unique number defined by the State, Zoning as an integer number indicating the numerical code of a zoning type and each land parcel belongs to one zoning type, Owner First Name and Owner Last Name as text indicating the...

  • please correct my answer. Problem 7.8 1 SELECT SUM (ASSIGN_HOURS) AS SumOfASSIGN_HOURS, SUM(ASSIGN_CHARGE) AS SumOfASSIGN_CHARGE FROM...

    please correct my answer. Problem 7.8 1 SELECT SUM (ASSIGN_HOURS) AS SumOfASSIGN_HOURS, SUM(ASSIGN_CHARGE) AS SumOfASSIGN_CHARGE FROM ASSIGNMENT, Problem 8 Write the SQL code to generate the total hours worked and the total charges made by all employees. The results are shown in Figure P7.8. Figure P7.8 Task Complete Problem 8 above. SQL View 0 out of 1 checks passed, Review the results below for more details. Run a SQL query to generate results Checks Incomplete SQL Database Test Problem 8...

  • Problem 33, chapter 7 from Database Systems 13th edition by Coronel Write a query to display...

    Problem 33, chapter 7 from Database Systems 13th edition by Coronel Write a query to display the employee number, last name, email address, title, and department name of each employee whose job title ends in the word “ASSOCIATE.” Sort the output by department name and employee title Problem 36, chapter 7 from Database Systems 13th edition by Coronel Write a query to display the number of products within each base and type combination, sorted by base and then by type...

  • Create the database and tables for the database. Show all SQL statements. Include primary and foreign...

    Create the database and tables for the database. Show all SQL statements. Include primary and foreign keys. Insert data into each table. Show select statements and display the output of each table. Note:Student’s name must be inserted into table as part of the data! Perform the SQL below: Query one table and use WHERE to filter the results. The SELECT clause should have a column list, not an asterisk (*). State the purpose of the query; show the query and...

  • For this set of Review Questions, we will create and use a database for the Wedgewood...

    For this set of Review Questions, we will create and use a database for the Wedgewood Pacific Corporation (WPC) that is similar to the Microsoft Access database we created and used in Chapters 1 and 2. Founded in 1957 in Seattle, Washington, WPC has grown into an internationally recognized organization. The company is located in two buildings. One building houses the Administration, Accounting, Finance, and Human Resources departments, and the second houses the Production, Marketing, and Information Systems departments. The...

  • database and sql problme THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED...

    database and sql problme THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED BELOW CREATE TABLE Department ( DECIMAL(5) VARCHAR(30) CHAR(5) DATE NOT NULL NOT NULL NOT NULL * Department number /*Department name * Department manager number */ /Manager start date DNumber DName Manager MSDate CONSTRAINT Department_PK PRIMARY KEY(DNumber) CONSTRAINT Department_CK UNIQUE(DName) CREATE TABLE DeptLocation DECIMAL(5) VARCHAR(50) NOT NULL NOT NULL DNumber * Department number */ * Department location */ Address CONSTRAINT DeptLocation_PK PRIMARY KEY(DNumber, Address) CONSTRAINT...

  • Help In Database: Next comes the data entry: Make up data for your database, or find...

    Help In Database: Next comes the data entry: Make up data for your database, or find real data. You can enter the data with INSERT statements, but it is much easier to use PhpAdmin. It has a form where you can type the data directly. Alternatively, you can use PhpAdmin to import CSV data (comma-separated values), which you can export from Excel. Include at least 3 rows in each of the entity relations, and as many rows as you need...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT