Ask DBMS Expert


Home >> DBMS

Description
Below diagram shows a relational diagram of a company's database, storing information about employees as well as the projects they are working on.

2166_figure.jpg

Appendices A and B provides some sample content of the various tables described in the above relational diagram. It is highly recommended you go through it as it gives you a clue as to the various attributes, data types and likely domain range / values.

Note that in the ASSIGNMENT table, the attribute named 'ASSIGN CHG HR' is related to the attribute 'JOB CHG HOUR' in the JOB table. However, there are some differences in their meanings, as follows:

JOB CHG HOUR - stores the most recently recorded hourly rate of a particular job, as of
a particular date (see attribute JOB_LAST_UPDATE)
ASSIGN CHG HR - maintains both 'current' and 'historical' hourly rates of a particular
job, (see attribute ASSIGN_DATE, for ASSIGN_JOB = 501)

Finally, do note that the attribute `JOB_CODE' in JOB and EMPLOYEE tables means the same thing as attribute `ASSIGN_JOB' in ASSIGNMENT table.

Creating Queries

Using the given database, follow the instructions in sequence, to create the queries for each question, in MS Access.

1) Write the SQL code to create the table named `EMP_1'. This table is a subset of the EMPLOYEE table, and the structure of the table is summarized as attached below.

2) After creating the table `EMP_1' in Qn 1), write the SQL code to enter the 1st 2 rows of data, based on the table attached below.

3) Instruction :
Assuming the 1st 2 rows of data specified in Qn 2) has been entered, import the rest of the data (from `EMP_1.txt' file that you downloaded), into your created table EMP_1.

4) Write the SQL code to list all attributes information for job code of 501.

5) Write the SQL code to change the job code to 501, for the person whose employee number (EMP_NUM) is 107.

6) Write the SQL code to delete the row for the person named Ramoras Anne', hired on Nov 15, 1987 and whose job code is 501. (Hint : Use logical operators to combine the criteria in your query)

7) Write the SQL code to create an empty table, named 'EMP_2'. EMP_2 should have the exact same attributes, relationships and constraints as table EMP_1.

8) After creating the empty table EMP_2 in Qn 7), write the SQL code to alter table EMP_2 to include a new attribute / columns named 'EMP -PCT'. The data type is 'NUMBER'. (Note : EMP_PCT represents a bonus percentage to be paid to each employee).

9) Write the SQL code to alter table EMP_2 to include another new attribute / columns named `PROJ NUM'. The data type is `CHAR(3)'.

10) Instruction :
Assuming Qns 7 - 9 have been done, import the rest of the data (from 'EMP_2.txt' file that you downloaded), into your created table EMP_2.

11) Referring to table EMP_2, write the SQL code to change the EMP_PCT value to 3.85, for the person whose employee number (EMP_NUM) is 103,

12) Referring to table EMP_2, using a single SQL command, write the SQL code that will change the project number (PROJ_NUM) to 18, for all employees whose job classification (JOB_CODE) is 500.

13) Referring to table EMP_2, using a single SQL command, write the SQL code that will change the project number (PROJ_NUM) to 25, for all employees whose job classification (JOB_CODE) is 502 or higher.
Note : after executing the SQL code in Qns 11 - 13), the table EMP_2 should contain the data attached in the figure below.

14) Referring to table EMP_2, write the SQL code that will change the PROJ_NUM TO 14, for those employees who were hired before Jan 1, 1994 and whose job code is at least 501.

15) Write the two SQL command sequences required to:
a) Create a temporary table named TEMP_1 whose structure is composed of the EMP2 attributes EMP_NUM and EMP PCT
b) Copy the matching EMP_2 values into the TEMP_1 table

16) Write the SQL command that will delete the newly created TEMP_1 table from the database

17) Referring to table EMP_2, write the SQL code to list all employees whose last names start with 'Smith'. (e.g. records of employees whose names are 'Smith' or 'Smithfield' should be included in the returned listing. Assume case sensitivity.)
Hint : Research on the use of 'LIKE' operator in string comparison, and the usage of asterisk as wildcard. E.g. ... LIKE 'kitty' will match all words what ends with 'kitty'.

18) Referring to the tables EMPLOYEE, PROJECT and JOB (in Appendices A & B), write the SQL code that will return the results as attached in the figure below

19) Write the SQL code to find the maximum bonus percentage in the EMP_2 table

20) Write the SQL code that will produce a listing for the data in the EMP_2 table in ascending order by the bonus percentage

21) Referring to table JOB, write the SQL code to find the average job's charge per hour.

22) Write the SQL code that will produce a listing for the data in JOB table, order by job's charge per hour, in descending order

23) Referring to the table EMPLOYEE, write the SQL code that will list only the distinct job code numbers

24) Write the SQL code to compute and update all the ASSIGN_CHARGE values in the ASSIGNMENT table, given that the value is given by the formula:

ASSIGN CHARGE = ASSIGN CHG HR *ASSIGN HOURS

25) Using the data from ASSIGNMENT and EMPLOYEE tables, write the SQL code that will produce the total number of hours worked for each employee, and the total charges based on those hours worked. The figure below shows a sample of the results your code should produce.

26) Write a query to produce the total number of hours and charges for each of the projects represented in the ASSIGNMENT table. The figure below shows a sample of the results your code should produce.
(Hint : the 2nd / 3rd column's names gives you a clue!)

27) Write the SQL code to generate the total hours worked and the total charges made by all employees. (Hint: This is a nested query. Analyze your answer for Qn 25 as the basis for the query that will produce the sample output attached in figure below)

28) Write the SQL code to generate the total hours worked and the total charges made to all projects. The results should be the same as those attached in sample output for Qn 27. (Hint: This is a nested query. Analyze your answer for Qn 26 as the basis for the query that will produce the sample output attached in figure in Qn 27)

Attachment:- db.zip

DBMS, Programming

  • Category:- DBMS
  • Reference No.:- M93099960
  • Price:- $90

Guranteed 48 Hours Delivery, In Price:- $90

Have any Question?


Related Questions in DBMS

Data mining assignment -in this assignment you are asked to

Data Mining Assignment - In this assignment you are asked to explore the use of neural networks for classification and numeric prediction. You are also asked to carry out a data mining investigation on a real-world data ...

Sql query assignment -for this assignment you are to write

SQL Query Assignment - For this assignment you are to write your answers in a word document. This assignment is in three parts: Part A (reporting queries), Part B (query performance), Part C (query design). For this assi ...

The groceries datasetimagine 10000 receipts sitting on your

The groceries Dataset Imagine 10000 receipts sitting on your table. Each receipt represents a transaction with items that were purchased. The receipt is a representation of stuff that went into a customer's basket. That ...

You are in a real estate business renting apartments to

You are in a real estate business renting apartments to customers. Your job is to define an appropriate schema using SQL DDL in MySQL. The relations are Property(Id, Address, NumberOfUnits), Unit(ApartmentNumber, Propert ...

Objectivethe objective of this lab is to be familiar with a

OBJECTIVE: The objective of this lab is to be familiar with a process in big data modeling. You're required to produce three big data models using the MS PowerPoint software. This tool is available on UMUC Virtual Deskto ...

The relation memberstudentid organizationid roleid stores

The relation Member(StudentId, OrganizationId, RoleId) stores the membership information of student joining organization. For example, ('S1', 'O2', 'R3') indicates that student with Id 'S1' joined the organization with i ...

Relational database exerciseyou have been assigned to a new

Relational Database Exercise: You have been assigned to a new development team. A client is requesting a relational database system to manage their present store with the anticipation of adding more stores in the future. ...

Relational database design a given the following business

Relational Database Design A) Given the following business rules, identify entity types, attributes (at least two attributes for each entity, including the primary key) and relationships, and then draw an Entity-Relation ...

We can represent a data set as a collection of object nodes

We can represent a data set as a collection of object nodes and a collection of attribute nodes, where there is a link between each object and each attribute, and where the weight of that link is the value of the object ...

Data model development and implementationpurpose of the

Data model development and implementation Purpose of the assessment (with ULO Mapping) The purpose of this assignment is to develop data models and map Database System into a standard development environment to gain unde ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As