You are on page 1of 7

Part 1:

Instructions: Using the diagram below, write the DDL code to create the following
entities into tables. The relationships of the tables should also be written on the
code. You can use SQL developer to solve this. Copy and paste the codes below.
Save the SQL scripts as Tech6_fullname. Save this document as
Tech2Document_fullname.
Part 2:
Answer the following numbers using the table given. Use SQL developer to solve
this.
Save the SQL script as: Tech7_fullname. Make sure you make the questions in the
worksheet as comments.
Then copy your answer and paste your code below each number in this
document.

Use the table above to answer the following by writing the SQL code. Do
this code in sequential order. Each number is related to the previous
number.
1. Create the table above. Job_id is the primary key.
2. Add a new column on the table named job_category that accepts a
string and it can be null.
3. Using the new table, insert a new row on the Jobs table. Use the
following data: Job_id: ST_Assist, Job_title: Stock Aid, Min_Salary:
5000, Max_salary: 13000, job_category: M_Operator.
4. Show the all the jobid, job title, the sum of the minimum salaries of
the employees and the average of the minimum salaries of the
employees that has an job title that ends with “Representative”.
Group it by their job_ids and job_titles. Show only the sum of the
MIN_salaries that are less than 5000. Then arrange it by job_id.
(Then draw the table of the result)
Part 3:
Write a correct SQL statement for each problem and show the result of the
statement. Use the tables below. You may use SQL developer to help you with
answering the questions. Copy and past the source code and the result after each
question.
Student
Student
Enrollment
StudentId StudName Age
EnrollmentId EnrollmentDate StudentId SubjId
A Mark 18 E100 Oct – 10 - 2015 A 1
B Matthew 17 E101 Oct – 11 - 2015 B 2
C Ruth 20 E102 Nov – 10 - 2015 C 3
E103 Dec – 15 – 2015 D 1
D John 15
E104 Feb – 1 – 2015 E 3
E Sally 18
E105 Mar – 10 – 2015 F 2
F James 17

Subject
SubjId SubjDescription Units Priceperunit
1 Math 3 400
2 Science 2 500
3 History 1 250

1.) Create an SQL statement that would show the minimum and maximum
units of a subject. ( 5 points)

2.) Create an SQL statement that would show the student name, enrollment
date and subject description of the student who is enrolled in Math or
Science. ( 5 points)

3.) Create a view, name it as EnrollDates, that would show all the enrollment
dates of students who are enrolled in the subject History. ( 5 points)
4.) Create a view name it as studentDetails, that would should show the
student name, enrollment date the total price per unit and subject
description of students who are enrolled on the subject Science or History.
( 5 points)

5.) Create a view, name it as BiggestPrice, that will show the subject id and
highest total price per unit of all the subjects. The view should show only
the highest total price per unit that are greater than 1000.
Part A:
Write a series of scripts that would create a new user, grant at least four system
and at least four object privileges. Each script should have a comment statement
what is statement is doing and its purpose. Save the script as Tech9_fullname.
Save this file as Tech3Document_fullname.
Write your answers below:

Part B:
Answer the following using SQL developer. Use the schema of HR to answer this.
Copy and paste your answer below each number. And also paste the result of
your answers.
Save the sql script as TechSumm10_fullname

1. Create a sequence that starts with 1, an interval of 2 and the biggest number is
999999. Name the sequence as Sequence1.
2. Create a view that will show all the salaries and names of employees in the
Administration department.
3. Create a synonym of the job_history table. Name the synonym as JHistory.

4. Create an anonymous block that would output your complete name of the
screen.
5. Create an anonymous block to get the average of 5 numbers. Each number
should come from the input of the user.

6. Create an anonymous block that will input the name of an employee, birthday,
address and age. The name of the employee, birthday and address should come
from the input of the user, while the age should be calculated based on his/her
birthday.

Part C:

Given the question below:

Save your scripts as Tech11_fullname


Write your answers below:
A.
B.
C.
D.
E.

You might also like