This action might not be possible to undo. Are you sure you want to continue?
59pm) Marks: 100 (25% towards the final grade)
Introduction A trigger is a special case of stored procedure that is fired during an event rather than being explicitly executed. A trigger is called automatically when an event is fired. In Oracle, a trigger can have the procedural code embedded in the body of the trigger; you can call out to another existing function or procedure, or a combination of both. The code in a trigger is generally the same as any procedure or function. Oracle triggers allow you to develop general-purpose database programs as well as routines that a Database Administrator can use to effectively manage a database. Some activities in this assignment involve with writing triggers to help a DBA to automate some of their daily tasks. In addition to that, in Task 5, you will get an opportunity to investigate contents of the Data Dictionary and retrieve valuable information for the Database Administrator. In Task 6 and 7, you will investigate the row-level security features in Oracle and implement your own security strategies.
Assignment requirements This is an individual assignment, to be submitted electronically using the WebLearn facility. It is due th by 11:59pm Sunday 9 October 2011, and contributes 25% towards the final result. All scripts or other material that is not original must be fully credited. That is, any material that is copied or derived from another source must be clearly identified as such and the original author must be identified. Sometimes students assist each other with an assignment, but end up working together too closely, so that the students' separate solutions have significant parts in common; unless the solutions were developed independently, they are regarded as plagiarised. The minimum penalty for plagiarism is loss of marks for that assignment. If this means that a hurdle requirement is not met, the student fails the course. Submission requirements: • All PL/SQL scripts should be in plain text. DO NOT SEND ANY DOC FILES! • Use the EXACT names given for the triggers and functions; also use the given SQL files to create any new tables. THIS IS IMPORTANT BECAUSE TESTING WILL BE DONE USING AUTOMATED SCRIPTS. • The report can be in either DOC or PDF formats. • DO NOT USE DIRECTORIES TO STORE YOUR FILES. USE A LOGICAL NAMING CONVENTION (i.e. task1.pdf, task2-1.sql, task2-2.sql etc.). • Additionally you can provide a readme.txt file for other information like student no., name etc. • Instructions to execute the PL/SQL scripts should be given as comments inside the scripts. • ZIP all your files and submit via WebLearn. DO NOT SEND RAR or 7Z FILES! • You can submit your assignment as many times as you want before the due date. Each submission will overwrite any previous submissions. Further Information: Any further inquiries regarding this assignment should be raised in the appropriate discussion forum in the BlackBoard.
MMBNAME. STARNUMB*) STAR (STARNUMB. AWRD. STARNAME. MPAA. MVNUMB*. NUMRENT. SALARY. BONUS. . DIRDIED) EMPLOYEE (EMPNUMB. dbastudent). ENDDATE.Preparation tasks Some activities of the assignment are based on the Movies Schema. Run following SQL commands. Your report should focus on the following aspects: • Scalability • Availability of data • Ease of migration from the existing system running on Oracle 8i system • Product Support/ Cost of maintenance • Total cost of ownership Your report should also highlight the risks the university will face if it decides to extend the use of current system. MVTITLE. 1. BRTHPLCE. Copy all the . SQL> @drop-movies SQL> @create-movies SQL> @populate-movies 4. check that everything is OK. CRIT. JOINDATE) MOVIE (MVNUMB. BORROW (TXNUMB. and clearly cite the sources (complete URLs) you extract information from. Oracle 11g – Single Server version 2. MMBADDR. 2. Follow these steps to build the sample database. DIRNAME. MMBCTY. YRMADE. you should invest some time on searching the Internet.g. The head of the IT has hired a DB consultant to investigate and recommend a suitable Database System to cater as the backend of the planned student management system. DIRNUMB*) MOVSTAR (MVNUMB*. 3. STARDIED) Primary keys are underlined. MMBNUMB*) DIRECTOR (DIRNUMB. To answer this task. The following products were short listed as suitable contenders. EMPNAME. EMPCITY.sql files from the Assignment 2 section (in Blackboard) to a location where you can access the Oracle database. E. DESCRIPTION) MEMBER (MMBNUMB. 1. which is currently plagued with capacity problems. STARBORN. Foreign keys are denoted by asterisks and refer to an attribute with the same name. You should provide suitable case studies/ examples highlighting those risks. STARTDATE. The current system uses an Oracle 8i database server to store data. MMBST. DIRBORN.e. Oracle 11g – Real Application Cluster (RAC) version Write a report analysing the suitability of each of these products highlighting their positives and negatives in the context of the university's database needs. Log in to Oracle as a non-privileged user (i. MVTYPE. as described below. BORDTE. SQL> SELECT COUNT(*) FROM employee. NOMS. Task 1: 30 Marks The University of XYZ is planning to upgrade their student management system. The DDL scripts and DML scripts to create and populate a sample Movies schema are provided along with this assignment specification. After populating tables.
Each log entry will include the username and the logout timestamp. Each log entry will include the username and the logon timestamp. 2. Write a Database Event Trigger – called logon_trigger which records all the logon events. System triggers – Database triggers and Schema triggers – fire whenever database-wide or schemaside events occur. start_time. Only a user with SYSDBA role should be able to create this trigger and will be saved in ORACLE userʼs tablespace. SHUTDOWN. Write a PL/SQL program to calculate and display the username and average session time for all database users. You must leave the end_time attribute blank (that will be updated by another trigger – see below). LOGON and LOGOFF. . You can assume that the log table with the following structure exists in the Oracle userʼs schema. SERVERERROR. you can safely assume that each user is allowed only one logon session at any given time. 1. user_action_log (username.Task 2: 15 Marks Auditing is a very important part of any administratorʼs duties. There are five database event triggers: STARTUP. This trigger will update an existing row (corresponds to the same user and has a blank end_time value) in the audit table called user_action_log. Only a user with SYSDBA role should be able to create this trigger and will be saved in ORACLE userʼs tablespace. This trigger will add a new row to the audit table called user_action_log. end_time) – use the given SQL script. 3. For simplicity. Write another Database Event Trigger – called logout_trigger which records all the logout events. Database Administrators extensively use triggers for auditing purposes and monitor database operations.
The free_space_data table has the following structure and you can assume it already exists. Oracle maintains a set of virtual tables that record current database activity. Ownerʼs username and the session status (whether it is Waiting or On CPU). not user IDs. Database administrators and other users should access only the V$ objects. gathering information on free space inside the database. (Note that. Views are created on these tables. For example. LOGON and LOGOFF. and the actual dynamic performance table related to this view is V_$DATAFILE. and so on. There are five database event triggers-STARTUP. not the V_$ objects. it is required to aggregate free space in each data file to get the total free space. However. Task 5: 10 Marks Throughout its operation. SYS owns the dynamic performance tables. free_space_data (tablespace_name. As a Database Administrator. and then public synonyms are created for the views. free_space. The synonym names begin with V$. by populating an error log table. say 1 minute). sum(bytes)/1024/1024 "MB Free" FROM dba_free_space WHERE tablespace_name = 'USERS' GROUP BY tablespace_name. along with tablespace name and timestamp. Write a SQL query to display details of current database sessions.Task 3: 15 Marks Administering a database requires running lots of tasks. timestamp) – use the given SQL script. Task 4: 10 Marks Database event triggers fire whenever database-wide events occur. for testing purposes as well as marking of your script. Write a PL/SQL script to compute the free space in USERS tablespace and store it in a audit table called free_space_data. 2. These tables are called dynamic performance tables. Create a job scheduler to run the above PL/SQL script every hour. you have been asked to monitor free space in the USERS tablespace. Your query must display usernames. SERVERERROR. it may be required to reduce this interval to a smaller unit. Create a Database event trigger called as AuditErr that will fire every time a server error occurs. 1. The error refers to any Oracle error. this table stores free space information for each data file used for the tablespace. called server_error_log (use the given SQL script). These triggers offer stunning possibilities for automated administration control to any DBA. in a real working environment we may only require to run it every hour. However. Your query should display Session ID. You should create the error lag table before-hand and when an error happens. This trigger can serve as a notification mechanism to an administrator. Examples include collecting statistics on database objects. the error code and details must be written back to this table. in some instances on-request and in some other cases in scheduled intervals. The following SQL query will show the free space in the USERS tablespace. SELECT tablespace_name. SHUTDOWN. analysing and reporting problems directly to the DBA. the V$DATAFILE view contains information about the database's datafiles. their names all begin with V_$. . therefore. After some research it is found that dba_free_space view in the data dictionary holds the required information.
This simply means that if you execute a command like SELECT * FROM EMPLOYEE. access to particular rows can be based on such considerations as the department to which employees belong. context-dependent. an Web order entry system can enforce access based on customer number.78 and the highest salary at $ 7897. such as organization. Activity: Employee table in the Movies database has 8 rows. customers can view their order status online (but only for their own orders). if John Doe (who belongs to Department 10) inputs the statement SELECT * FROM EMPLOYEE. account number. Virtual private database provides fine-grained access control which is data-driven.Task 6: 10 Marks A view can provide value-based security for the information in a table. Direct or indirect access to a table with an attached security policy causes the database to consult a function implementing the policy. The policy function returns an access condition known as a predicate (a WHERE clause) which the database appends to the user's SQL statement. Virtual Private Database in Oracle is the ability to perform query modification based on a security policy you have defined in a package. and row-based. or other significant factors.500 or less) will be applied to SQL statements. with the lowest salary at $ 1232. For example. you can use VPD to tack on the clause WHERE DEPT = 10. thus dynamically modifying the user's data access. in which you create your own implementation of row level security. while sales representatives can view multiple orders. and whether the user is a customer or a sales representative. In this way. You can implement VPD by writing a stored procedure to append a SQL predicate to each SQL statement to control row level access for that statement. It has a salary attribute. Write an RLS Policy that defines when and how the above predicate (i.e. cost centre. For example. For any table with data.500 or less. A much more granular form of data access is row level access. and associated with a table or view. their job responsibility or title.78 1. A secure application context enables access conditions to be based on virtually any attributes an application deems significant. restrict users to seeing only employees with a salary of 1. . This way query modification is used to restrict data access to certain rows. or position. but only for their own customers. 2. Create a FUNCTION filter_sal that restrict users to seeing only employees with a salary of 1. The Virtual Private Database is enabled by associating one or more security policies with tables or views. One approach is called Virtual Private Database.
78 Melbourne Tester Task 7: 10 Marks In the previous exercise. you were asked to create a policy that returns a predicate string that is constant. EMPNUMB EMPNAME STARTDATE ENDDATE SALARY EMPCITY DESCRIPTION --------------------------------------------------------------------------01 Jason Martin 25-JUL-96 25-JUL-06 1234. he sees only one row – his own. For instance.It should only return details of employees with a salary of 1. This is a dynamic requirement. as follows: As an example: SQL> SELECT * FROM employee. As an example: SELECT * FROM EMPLOYEE. If the user ʻ01ʼ (remember that Jason Martin is the name of an employee in the table employee) logs in and selects from the table. .56 Geelong Programmer In order to test this you may create a user ʻ01ʼ. The solution to this script should contain all step-by-step instructions for the marker – any ambiguity will lead to loss of marks. you will need to build a filter based on the user issuing the query. For example. Now create a dynamic RSL Policy function that will compare the EMPNUMB column with the USER (i. SAL <= 1500. EMPNUMB EMPNAME STARTDATE ENDDATE SALARY EMPCITY DESCRIPTION --------------------------------------------------------------------------01 Jason Martin 25-JUL-96 25-JUL-06 1234.500 or less. not all records in a table. In most cases. In real life. the HR application may require that users see only their own records.e. as it needs to be evaluated for each employee who logs in. such a scenario is not very common. the name of the currently logged-in user).56 Geelong Programmer 08 James Cat 17-SEP-96 15-APR-02 1232.
YOU MUST SUBMIT ALL THE INSTRUCTIONS IN A STEP-BY-STEP MANNER TO TEST SCRIPTS FOR EACH OF THE TASKS. Any extension related request should be emailed to the head tutor – halil (halil.What to Submit.edu. For the report use ONLY . When. DO NOT SEND RAR 7ZIP FILES! Penalties for late submissions Late submissions of assignments will be penalised as follows. PUT THESE INSTRUCTIONS AS COMMENTS INSIDE EACH SQL SCRIPT.ali@rmit. The lesser information you provide the more marks you will loose. task1. and How What All the PL/SQL scripts and triggers should be submitted in plain-text format.e.sql etc). When th This assignment is due at 11:59pm at Sunday October 9 2011.doc or . task2-1. .sql. For 1 to 5 days late. How You will submit your files using WebLearn. ADDITIONALLY YOU CAN PROVIDE A readme. NAME EACH FILE IN SOME LOGICAL MANNER (i. task2-2.txt FILE. Zip all the submission files into a one ZIP file and submit it. 100% penalty for assignments submitted after 5 days.pdf.au). a penalty of 10% per day. DO NOT USE DIRECTORIES IN YOUR SUBMISSION. You can use either WinZip or GNU gzip to zip your submission.pdf files.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.