Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Page |1

INFORMATION TECHNOLOGY AND INFORMATION SYSTEM


DEPARTMENT

ADVANCED DATABASE MANAGEMENT SYSTEM

EXERCISE

8
CREATING OTHER DATABASE OBJECTS

John Rey J. Ubas 29035//29036 IT 202


NAME SECTION
April 13, 2023 April 13, 2023
DATE PERFORMED DATE FINISHED

GJPRosales
Page |2

I. OBJECTIVES

At the end of this exercise, students must be able to:

a.) create simple and complex views.


b.) apply with check option constraint to a view.

II. BACKGROUND INFORMATION

In order to accomplish this exercise, the student must have a clear understanding of the
following topics:
• Create simple and complex views.
• Retrieve data from views.

III. EXPERIMENTAL PROCEDURE

Write SQL statement to do the following tasks:

1. The staff in the HR department wants to hide some of the data in the EMPLOYEES
table. They want a view called EMPLOYEES_VU based on the employee
numbers, employee names, and department numbers from the EMPLOYEES
table. They want the heading for the employee name to be EMPLOYEE.

2. Confirm that the view works. Display the contents of the EMPLOYEES_VU view.

GJPRosales
Page |3

3. Using your EMPLOYEES_VU view, write a query for the HR department to display
all employee names and department numbers.

GJPRosales
Page |4

4. Department 50 needs access to its employee data. Create a view named DEPT50
that contains the employee numbers, employee last names, and department
numbers for all employees in department 50. You have been asked to label the
view columns EMPNO, EMPLOYEE, and DEPTNO. For security purposes, do not
allow an employee to be reassigned to another department through the view.

5. Display the structure and contents of the DEPT50 view.

GJPRosales
Page |5

6. Test your view. Attempt to reassign Matos to department 80.

7. You need a sequence that can be used with the PRIMARY KEY column of the
DEPARTMENTS table. The sequence should start at 280 and have a maximum
value of 1,000. Have your sequence increment by 10. Name the sequence
DEPT_ID_SEQ.

GJPRosales
Page |6

8. To test your sequence, write a script to insert two rows in the DEPARTMENTS
table. Be sure to use the sequence that you created for the ID column. Add two
departments: Education and Administration.

9. Confirm your additions.

10. Create a non-unique index on the NAME column in the DEPARTMENTS table.

GJPRosales
Page |7

11. Create a synonym for your EMPLOYEES table. Call it EMP.

IV. QUESTION AND ANSWER

1. When you attempt to reassign Matos to department 80 (step 6), what was
the result of the query? Explain.

The result of the query is that it resulted into an error where it says,
The
attempted insert or update failed because the target view either specifies
WITH CHECK OPTION or spans a view that specifies WITH CHECK OPTION and one
or more rows resulting from the operation did not qualify under the CHECK
OPTION constraint. I think one of the reasons that this leads into an error is that
my SQL is not updated to the current version where it can’t read nor have access
to the codes that requires an update version also from the error, I’ve done it in the
previous step whereas it should run smoothly but instead it didn’t.

V. REFERENCES

Hoffer, J.A., Prescott, M.B., McFadden, F.R. (2016). Modern Database Management
12th Edition, Prentice Hall.
Microsoft. (2012). Database Administration Fundamentals . USA: Wiley.

GJPRosales
Page |8

GJPRosales

You might also like