MONASH UNIVERSITY. Faculty of Information Technology



Similar documents
Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database 12c: Introduction to SQL Ed 1.1

Oracle 10g PL/SQL Training

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Chapter 1. Writing Basic. SQL Statements

Oracle Database: SQL and PL/SQL Fundamentals

SQL Introduction Chapter 7, sections 1 & 4. Introduction to SQL. Introduction to SQL. Introduction to SQL

There are five fields or columns, with names and types as shown above.

Oracle SQL. Course Summary. Duration. Objectives

Darshan Institute of Engineering & Technology PL_SQL

Oracle Database: SQL and PL/SQL Fundamentals NEW

Producing Readable Output with SQL*Plus

Oracle Database: Introduction to SQL

Oracle Database: Introduction to SQL

Developing SQL and PL/SQL with JDeveloper

Databases and BigData


IT2305 Database Systems I (Compulsory)

Scheme G. Sample Test Paper-I

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Oracle 11g PL/SQL training

IT2304: Database Systems 1 (DBS 1)

Oracle Database 10g: Introduction to SQL

Triggers & Packages. {INSERT [OR] UPDATE [OR] DELETE}: This specifies the DML operation.

Instant SQL Programming

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

Handling Exceptions. Schedule: Timing Topic. 45 minutes Lecture 20 minutes Practice 65 minutes Total

Oracle Database 10g Express

Oracle Database: Introduction to SQL

Database 10g Edition: All possible 10g features, either bundled or available at additional cost.

SQL. Short introduction

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

Lecture 6. SQL, Logical DB Design

How To Create A Table In Sql (Ahem)

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

Database Access from a Programming Language: Database Access from a Programming Language

Database Access from a Programming Language:

Elena Baralis, Silvia Chiusano Politecnico di Torino. Pag. 1. Physical Design. Phases of database design. Physical design: Inputs.

Oracle Database 11g SQL

5.1 Database Schema Schema Generation in SQL

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

Appendix A Practices and Solutions

Mini User's Guide for SQL*Plus T. J. Teorey

Oracle For Beginners Page : 1

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

Managing Objects with Data Dictionary Views. Copyright 2006, Oracle. All rights reserved.

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

SQL*Plus User s Guide and Reference

BCA. Database Management System

Topics Advanced PL/SQL, Integration with PROIV SuperLayer and use within Glovia

Conversion Functions

3.GETTING STARTED WITH ORACLE8i

Table Backup and Recovery using SQL*Plus

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

Review of Business Information Systems Third Quarter 2013 Volume 17, Number 3

Oracle/SQL Tutorial 1

ORACLE 9I / 10G / 11G / PL/SQL COURSE CONTENT

Programming with SQL

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Database Design Patterns. Winter Lecture 24

Developing Rich Web Applications with Oracle ADF and Oracle WebCenter Portal

2. Oracle SQL*PLUS Winter Some SQL Commands. To connect to a CS server, do:

Oracle(PL/SQL) Training

Oracle Database: Program with PL/SQL

Oracle Database: Develop PL/SQL Program Units

Displaying Data from Multiple Tables. Chapter 4

EECS 647: Introduction to Database Systems

Information Systems SQL. Nikolaj Popov

CPS352 Database Systems: Design Project

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. COURSE CURRICULUM COURSE TITLE: DATABASE MANAGEMENT (Code: ) Information Technology

TO_CHAR Function with Dates

CIS 631 Database Management Systems Sample Final Exam

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

1 File Processing Systems

Chapter 9, More SQL: Assertions, Views, and Programming Techniques

Setting up SQL Translation Framework OBE for Database 12cR1

ATTACHMENT 6 SQL Server 2012 Programming Standards

Programa de Actualización Profesional ACTI Oracle Database 11g: SQL Tuning Workshop

Elena Baralis, Silvia Chiusano Politecnico di Torino. Pag. 1. Active database systems. Triggers. Triggers. Active database systems.

A Brief Introduction to MySQL

PL/SQL. Database Procedural Programming PL/SQL and Embedded SQL. Procedures and Functions

Structured Query Language. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

AUTHENTICATION... 2 Step 1:Set up your LDAP server... 2 Step 2: Set up your username... 4 WRITEBACK REPORT... 8 Step 1: Table structures...

Using SQL Server Management Studio

Oracle PL/SQL Language. CIS 331: Introduction to Database Systems

1Z0-117 Oracle Database 11g Release 2: SQL Tuning. Oracle

An Introduction to PL/SQL. Mehdi Azarmi

Creating PL/SQL Blocks. Copyright 2007, Oracle. All rights reserved.

Procedural Extension to SQL using Triggers. SS Chung

Introduction to PL/SQL Programming

Relational Database Basics Review

DBMS / Business Intelligence, SQL Server

Introducing Oracle s SQL Developer

Lab Assignment Creating a Relational Database Schema from ER Diagram, Populating the Database and Querying over the database with SQL

æ A collection of interrelated and persistent data èusually referred to as the database èdbèè.

Oracle EXAM - 1Z Oracle Database 11g Release 2: SQL Tuning. Buy Full Product.

Transcription:

CSE2132/CSE9002 - Tutorial 1 Database Concept Exercises TOPICS - Database Concepts; Introduction to Oracle Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott and McFadden Chapter 1 Review Questions 1,2,3,4,8 Part2 - Use of Oracle During the first tutorial students are required to log in to the computer and invoke the database management system Oracle. The following steps are to be carried out. 1. Students must first connect to the network. 2. Choose Programs from the start menu. 3. Choose Development. 4. This will show them choices for Oracle and Gershwin and students should choose Oracle. 5. This will show a number of choices and students should choose Oracle- Orahome 92. 6. This will show a number of choices and students should choose Application Development. 7. This will show a number of choices and students should choose either SQLPlus or SQLPlus worksheet(recommended). If students choose SQLPlus Worksheet they will then see a window requesting Username: enter s followed by their student number Password: initially this is student Service: Enter CSE2132 which is the database name They will then be able to enter SQL commands and execute them by clicking on the lightning bolt icon. If students choose SQLPlus they will see a window requesting Username: enter s followed by their student number Password: initially this is student Host String: Enter CSE2132 They will then be able to enter SQL Plus commands via command line mode, which can be a little tedious.

6. Changing Passwords In SQL Worksheet the command to change a password is alter user username identified by newpassword; In SQL Plus 8.0 the commands to change a password are as above and also the command password which then causes the user to be prompted for the old password, the new password and a confirmation of the new password. 7. Either from the SQL command line or within the SQL worksheet try some of the following commands which look at some of the tables in the Oracle Data Dictionary. SELECT TABLE_NAME, COMMENTS FROM DICT; The next command selects all the rows in a table called EMP which is owned by the user called LECTURER SELECT * FROM LECTURER.EMP; The next command attempts to delete the rows in the table EMP but it fails as the table is not owned by the student.(note the error message) DELETE FROM LECTURER.EMP WHERE ENO=7369; The next command shows all columns and all rows in USER_TABLES. (Students may not have any tables yet. SELECT * FROM USER_TABLES; (TABS is a synonym for USER_TABLES) It is possible to see the structure of a table with the DESCRIBE command eg. DESCRIBE USER_TABLES; You could then enter individual column names eg. SELECT table_name, num_rows FROM USER_TABLES; Students should explore the tables using these simple commands to familiarize themselves with the Oracle Data Dictionary.

CSE2132/CSE9002 - Tutorial 2 Relational Data Model TOPICS - Relational Data Model, SQL Data Definition Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott and McFadden Chapter 2 Review Questions 2,3,10,11,15 Hoffer,Prescott and McFadden Chapter 5 Review Questions 4,5,13,14 Part 2 The aim of this exercise is to create tables, add some data, modify that data, perform some simple retrieval and finally remove any temporary tables. The situation we wish to represent is that of students enrolled in classes. For each student we need to store student number, name, street address, suburb, enrolment date and up to 8 subject codes. Each subject is described by a subject code, subject name, semester that it is run in and the teacher's name. The required relations (in third normal form) are SUBJECT (subcode, subname, semester, teacher) STUDENT (sno, sname, street, suburb, enrol_date) CLASS (subcode, sno) Decide on the datatype for each attribute (Oracle datatypes include char(w), varchar2(w), number, number(w), number(w,d), date and long). The following is some sample subject data. Make up at least 6 sample student records and their corresponding class enrolment. CODE NAME SEM TEACHER CSE1130 Computer systems 1 Brown CSE1140 Operating systems 2 Black CSE2138 Database Systems 1 White CSE3000 Database Design 1 Green EXERCISES. 1. Use the Create Table statement to define the tables above. CREATE TABLE tablename (columnname datatype{,columnname datatype}) 2. Use the Insert command to add data to the defined tables. For example, INSERT INTO SUBJECT (subcode,subname,sem,teacher) VALUES('CSE1130', 'Computer Systems',1,'Brown') etc for other values. It is recommended to save these commands to an edit file so they can be easily executed again if need be.

3. Once data is in the database we may retrieve all or part of it using the SELECT statement. For example to find out which students live in Caulfield, select sname from student where suburb = 'Caulfield' ; Find i) which subjects run in semester 1. ii) the student nos. of students enrolled in CSE2138. iii) students who live in Caulfield or Malvern. There are many forms and options for the select statement; more of them will be covered next week. 4. Once data is in the tables it may be altered using the UPDATE statement. For example to change the teacher for CSE1130 from Brown to Grey update subject set teacher = 'Grey' where subcode = 'CSE1130' ; i) change the subject description of CSE1130 to "Introduction to Computers" ii) change the suburb of students who live in Caulfield to Caulfield Heights. 5. One of the useful features of Oracle is the DESCRIBE command. The DESCRIBE command displays a specified tables definition which includes column names and data types. It may be abbreviated to DESC. e.g. DESC SUBJECT; Check the definition of all the tables you have created. 6. A number of tables are maintained by Oracle to record data about data ie.metadata. One such table is USER_TABLES another is ALL_TABLES ; They are used to record what tables are belong to the user and what tables exist in the current database. Use a select statement to find out which tables belong to you. You would expect that the three tables created above are there among a large number of data dictionary tables. 7. Finally, data may also be deleted from tables when it is no longer needed. This may be done one row at a time or for an entire table. For example to delete student Smith from the STUDENT table DELETE FROM STUDENT WHERE SNAME = 'Smith' ; Note i) All Smith's would be deleted. ii) This may cause referential integrity problems if Smith was actually enrolled in any subject. DROP TABLE tablename ; The above statement would delete an entire table. Remove all the tables that you have created. Use a SELECT on USER_TABLES to verify they are gone.

CSE2132/CSE9002 - Tutorial 3 SQL Data Manipulation TOPICS - SQL DML Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott and McFadden Chapter 7 Review Questions 1,5,8,10,11,16 Part 2 Three tables have been created in the CSE2132/CSE9002 database that may be used for the following exercises. Their structure is as follows: EMP(eno, ename,jid,age, hiredate, salary, dno, mgr) DEPT(dno,dname,floor) JOB(jid,jtitle,lowsal,highsal) These tables have the following data: EMP Eno Ename Jid Age Hiredate Salary Dno Mgr 7369 Smith 5 35 17 Dec 90 800 20 7902 7499 Allen 4 46 20 Feb 91 1600 30 7698 7521 Ward 4 43 22 Feb 91 1250 30 7698 7566 Jones 2 51 02 Apr 91 2935 20 7839 7654 Martin 4 38 28 Sep 91 1250 30 7698 7698 Blake 2 53 01 May 91 2850 30 7839 7782 Clark 2 48 09 Jun 91 2450 10 7839 7788 Scott 3 45 09 Jul 97 3000 20 7566 7839 King 1 57 17 Nov 91 5000 10 7488 Turner 4 33 08 Sep 91 1500 30 7698 7876 Adams 5 29 13 Jul 97 1100 20 7788 7900 James 5 30 13 Dec 92 950 30 7698 7902 Ford 3 43 03 Dec 91 3000 20 7566 7934 Miller 5 31 23 Jan 94 1300 10 7782 DEPT Dno Dname Floor 10 Accounting Top 20 Research Basement 30 Sales Ground 40 Operations Second JOB Jid Jtitle Lowsal Highsal 1 President 3001 9999 2 Manager 2001 3000 3 Analyst 1401 2000 4 Salesperson 1201 1400 5 Clerk 700 1200 (Note that the table design could be improved - Age would be better stored as a birthdate.)

EXERCISES (Not necessarily in order of difficulty) To create the tables from the existing tables owned by the user called LECTURER perform the following steps:- i) Go into the SQL option of Oracle (using database CSE2132/CSE9002 ). ii) Type the following :- CREATE TABLE tablename AS SELECT * FROM lecturer.tablename iii) The new tables will be prefixed with your userid now so they can updated by you. Write and execute the necessary SQL statements to perform the following tasks. 1. List all employees whose name begins with 'A'. 2. Select all those employees who don't have a manager. 3. List employee name, number and salary for those employees who earn in the range 1200 to 1400. 4. Give all the employees in the RESEARCH department a 10% pay rise. Verify that this has been done by listing all their details before and after the rise. 5. Create a view called OLDTIMERS of employees who were hired before 1992. (Hint: use the TO_DATE function.) 6. Find the number of CLERKS employed. Give it a descriptive heading. 7. Find the average salary for each job type and the number of people employed in each job. 8. List the employee names, number of years with the company and the DAY they were hired on. (Hint: need to use the first four date manipulation functions in appendix.) 9. List the yearly salaries for the Managers. 10.List the employees with the lowest and highest salary. 11.List full details of departments that don't have any employees. 12.Get the names and salaries of all the analysts earning more than 1200 who are based in department 20. Sort the answer by ascending name. 13. For each department, list its name and number together with the total salary paid to employees in that department. 14. List department names, their location and a list of all employees who work in the departments. 15. Get a list of all people who manage anyone else and the people they manage i.e. a series of pairs; order by manager name. 16. Find all the employees in department 20 who have a job that is the same as anyone in the accounting department.

Appendix: Date Functions and arithmetic SYSDATE gives the system date. TO_CHAR(date,format) see formats below TO_DATE(string,format) MONTHS_BETWEEN(date2,date1) gives date2-date1 in months(can be fractional months). ADD_MONTHS(date,count) adds count months to date e.g. ADD_MONTHS(hiredate,6) would give a date six months later. LAST _DAY(date) gives date of last day of month that date is in. NEXT_DAY(date,'day' gives the date of next day after date, where 'day' is 'Monday' and so on. GREATEST(date1,date2,date3,...) picks the latest date from a list of dates. LEAST(date1,date2,date3,...) picks the earliest date from a list of dates. Some Date Formats (used with TO_CHAR and TO_DATE) MM number of : 12 MON Three letter abbreviation of month: XXII MONTH Month fully spelled out: AUGUST DDD Number of days in year, since Jan1: 354 DD Number of days in month: 23 D Number days in week: 6 DY Three letter abbreviation of day: FRI DAY Day fully spelled out: FRIDAY YYYY Full four digit year: 1946 SYYYY Signed year, 1000 B.C = -1000 YYY Last three digits of year: 946 YY Last two digits of year: 46 Y Last digit of year: RR Last two digits of year relative from current date YEAR Year spelled out: NINETEEN-FORTY-SIX Q Number of quarter: 3 WW Number of weeks in year: 46 W Number of weeks in month: 3 HH Hours of day, always 1-12: 11 HH24 Hours of day, 24 hour clock...there are others.

CSE2132/CSE9002 - Tutorial 4 Conceptual Data Modeling Part 1 (To be done in the students own time then discussed in class if necessary except Problems and Exercises 4a,4c and 4d which can be done in the lab.) Hoffer,Prescott and McFadden Chapter 3 Review Questions 1,2,3,11,12,13,14 Problems and Exercises 3,4a,4c,4d (Use GERSHWIN to do the questions to gain exposure to an automated support tool in the lab.)

CSE2132/CSE9002 - Tutorial 5 Logical Database Design Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott and McFadden Chapter 5 Review Questions 9,15 Hoffer,Prescott and McFadden Chapter 6 Review Questions 12,13,14 Part 2 The aim of the exercises is to have students go through the major steps of the database design lifecycle. It could be done manually but students are asked to employ GERSHWIN for some steps to gain exposure to an automated support tool. Consider the following ER diagram to support the University database (modified from Elmasri & Navathe Figure 12.10) You should enter the following into GERSHWIN as is without the foreign keys and linking tables(or associative entity) as they will be automatically generated when generate DSD(Data Structure Diagram) is chosen from the menu item:- Department(Dname,Doffice,Dphone) Subject(Subject_No,Subject_Name,Points) Student(Student_Number,Sname,Saddress) Also note that the relationship between Subject and Student has an attribute Grade Lecturer(Lecturer_Name,Position,Office,Phone) Prerequisites(Prereq_Subject_No) Also note that the relationship between Subject and Prerequisite is PE-WE relationship or at least can be represented in this way for the purposes of the exercise.(i.e. Parent Entity - Weak Entity relationship) It is possible that subjects may not belong to any Department. Prerequisites must belong to a Subject 500 Department 10 Prerequisites 120 Subject Student 2000 50 Lecturer

You are required to produce the following: 1. An entity-relationship diagram (similar to above) using the software called GERSHWIN - listing the primary keys, and cardinalities of the relations you produce. Also note that foreign keys need not be included as GERSHWIN inserts these automatically in the Data Structure Diagram. 2. A logical Data Structure Diagram generated by GERSHWIN. Note that the many to many relationship between subject and student will automatically be resolved by GERSHWIN. 3. Create table statements with appropriate data types (i.e. variable length columns and nulls). 4. Given the data volumes and processing needs given below, consider what changes you might make to the logical model in setting up the implementation model database, for example any derived data, introduced codes or redundancy. Departments - 10 Lecturers - 50 Students - 2000 Subjects - 120 Prerequisites - 500 Most students enroll in approx. 24 subjects during their course. The administration want rapid access to the number of students enrolled in any subject. They require both ad hoc queries and regular reports on lecturers workloads ( total hours taught weekly). When enquiries are made on what students are doing a subject the student surname must be shown as well as the student number.

CSE2132/CSE9002 - Tutorial 6 Normalization Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott and McFadden Chapter 5 Review Questions 1,2,3,6,7,8,11 Problems and Exercises 3,4,5

CSE2132/CSE9002 - Tutorial 7 Relational Integrity Rules TOPICS - Integrity ; Domains Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott and McFadden Chapter 5 Review Question 12,18 Hoffer,Prescott and McFadden Chapter 8 Review Question 7,8 Part 2 1. Using the following attributes indicate the primary and foreign keys. Provide a list of create table statements for all the required tables. For each table include the SQL to enforce the primary and foreign key constraints(decide if the delete should be restricted or cascading, which are the only two options in Oracle). Use the Oracle syntax to show columns that should be not null(e.g. surname) and/or unique(e.g. dept_name). Also include a check constraint on a column (e.g. that dept_name is LAW or MEDICINE or SCIENCE) and a check constraint on a table (e.g. surname is different from first name). (Execute create tables statements for the following table structures in the labs) Lecturer(l_code char(3), l_surname char(15), first_name char(15), d_o_b date,) Subject(S_code char(4), subject_title char(20), l_code char(3)) Student(St_id char(10), surname char(15), first_name c(15), address char(20)) Student_enrolment(St_id char(10), s_code char(4), result char(20)) Enter some data and see the effect when the data does and does not conform to the constraints. 2. Write a trigger to raise an error if any attempt is made to update the result column in student_enrolment. Check that the trigger works by attempting the update.

Part 1 Questions MONASH UNIVERSITY Faculty Information Technology CSE2132/CSE9002 - Tutorial 8&9 PL/SQL 1. What are the advantages of using PL/ SQL? 2. The procedural and SQL staements in a PL/SQL block are processed by the SQL statement executor and the Procedural statement executor. Explain how this works in a client server environment and where the components reside. 3. What are 4 of the places (or vehicles) for the use of PL/SQL? What is the purpose of each? 4. What restrictions apply to the use of PL/SQL in triggers? 5. What is the difference between an Implicit and Explicit cursor?. 6. When is it appropriate to use explicit cursors, give an example? 7. State the steps involved in using explicit cursors. Part 2 In the Lab 1. Alter the table subject(created in week 7 tutorial) to add a column no_of_students. 2.Write a trigger to disallow more than 3 enrolments in a subjects which is checked when the table student_enrolment has an insert or update on it. 3.Check that it works. 4.Issue the following command. ALTER TRIGGER triggername DISABLE; Check it's effect. Then issue an ENABLE ALTER TRIGGER triggername ENABLE; 5.Maintain the value of no_of_students as an additional task in the trigger.

Examples of Triggers with PL/SQL REM This file contains the trigger examples REM used in Chapter 5 of "Oracle PL/SQL Programming" by Scott Urman. The example following shows a Cursor FOR Loop which provides two important shortcuts for cursor processing. The record v_statsrecord is not declared in the declaritive section of the block. It is implicitly declared by the PL/SQL compiler. Secondly the cursor c_statistics is implicitly opened, fetched from, and closed by the loop. The type of this variable is c_statistics%rowtype. REM *** Chapter 5: Creating a Trigger *** CREATE OR REPLACE TRIGGER UpdateMajorStats /* Keeps the major_stats table up-to-date with changes made to the students table. */ AFTER INSERT OR DELETE OR UPDATE ON students DECLARE CURSOR c_statistics IS SELECT major, COUNT(*) total_students, SUM(current_credits) total_credits FROM students GROUP BY major; BEGIN /* Loop through each major. Attempt to update the statistics in major_stats corresponding to this major. If the row doesn't exist, create it. */ FOR v_statsrecord in c_statistics LOOP UPDATE major_stats SET total_credits = v_statsrecord.total_credits, total_students = v_statsrecord.total_students WHERE major = v_statsrecord.major; /* Check to see if the row exists. */ IF SQL%NOTFOUND THEN INSERT INTO major_stats (major, total_credits, total_students) VALUES (v_statsrecord.major, v_statsrecord.total_credits, v_statsrecord.total_students); END IF; END LOOP; END UpdateMajorStats;

/

CSE2132/CSE9002 - Tutorial 10 Underlying Data Structures - Oracle File Organizations Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott and McFadden Chapter 6 Review Questions 1,2,3,4 Part 2 1. What is the difference between a file organization and an access method? 2. What are the basic types of file organizations? Do the available Oracle file structures correspond to any of these? 3. You are developing a project which requires the storage of data as an indexed file, but the only file handling facilities are sequential and relative. Your decision then is to use a serially-loaded relative file as the data file with an index being built in the load program. In the first load run, the data and the order provided is:- 103,13,76,44,10,180,56,3,78,35,66,12,156,122,19 (a) show what the index would be after the load run if a binary tree is used for the index. Draw the index as a tree structure and also show how this would appear as a linear table in memory e.g. Drawn as a tree 103 13 76 The same thing as a linear table (which is how it is really stored in memory) RRN Leftpointer Key Rightpointer 1 2 103 null 2 null 13 3 3 null 76 null (b) On reflection you decide to use the B+Tree model to store the index and to store 3 key values at each node. Show how the index would appear at the end of the load run. Illustrate as a tree structure only (it would have to be implemented as a linear table index). (c) Having stabilized on the B+ tree index, the next load run present the values 14,15,101,102 and 103 to be added. What is the effect of this on the index.? What safeguards would be necessary in the load program?

CSE2132/CSE9002 - Tutorial 11 Indexes Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott and McFadden Chapter 6 Review Questions 16,18,19 Problems and Exercises 10,11 Part 2 Consider the following relations (from week 7) to support the University database 1. Given the data volumes and processing needs given below. What indexes and or clusters would be helpful? Should the indexes be btree or bitmap types? Should the clusters be indexed or hash type.? Justify your decisions. Write the CREATE INDEX/CREATE TABLE and CREATE CLUSTER statements to implement your choices in Oracle. (When in the lab enter these statements into Oracle) Nb: Two new attributes have been included; short_course(y/n) and hours_week. Lecturer(L_code c3, l_surname c20, first_name c20, d_o_b date) Subject(S_code c4, subject_title c20, l_code c3, hours_week c2) Student(St_id c10, surname c20, first_name c20, address c30,short_course(y/n) c1) Student_enrolment(St_id c10, S_code c4, result c2) Lecturers - 50 Students - 2000 Subjects - 120 Most students enrol in approx 24 subjects during their course. The administration want rapid access to the number of students enrolled in any subject. They require both adhoc queries and regular reports on lecturers workloads (total hours taught weekly). They also need to know whether a particular student is enrolled in a short course or degree course. Before enrolling students into a subject the admin people use an online system to check whether or not a particular student has failed the subject previously - previous fails may lead to exclusion. n.b.[the administration is due for an equipment upgrade but until they get it, storage space is at a premium.] 2. Calculate the approximate Table and Index file sizes for each of the indexes you have identified above. For the indexes assume the index entries consist of the primary key plus a 9 byte row identifier and one entry per row.

CSE2132/CSE9002 - Tutorial 12 Distributed Database Tutorial Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott and McFadden Chapter 13 Review Questions 1a,b,e,2,4,5,6,7,8,9 Problems and Exercises 1,4