Ask DBMS Expert


Home >> DBMS

Question 1

Write a stored procedure that accepts the model name of a car as the input parameter and provides the number of cars belonging to that model as the output parameter. The procedure should also display the description of the car model.

Procedure:

1. Create the procedure that should have one IN parameter (p_model) and one OUT parameter (p_noofcars)

2. Use an implicit cursor and a SQL function to calculate the number of cars belonging to the particular car model and assign that value to the OUT parameter.

3. Use another implicit cursor to display the description belonging to the particular car model.

Submit the code to create the procedure and the code to call the procedure in a PL/SQL block. Value for the input parameter for the procedure should be ‘FERR TR'. You should display the value of the OUT parameter returned, i.e. the number of cars belonging to the car model.

Provide a screen dump of the output when the calling PL/SQL block is run.


Question 2

Write a function that displays the most recent date of rental for a particular car (registration) for all completed bookings made for that car.

Write a second function that displays the maximum rental period for a particular car (registration) for all completed bookings made for that car.

For both the functions, you should check for completed bookings, i.e. miles_in is not null.

Write ONE SQL statement that displays the registration, model name and cost for each car and calls the two functions to display the most recent date of rental and the maximum rental period for that car.

Display the output of the SQL statement.

Question 3

The car hire company is concerned about possible unauthorised changes to customer details that may compromise the company's security and privacy policies. You will create a database trigger to monitor such changes to some important columns in the I_CUSTOMER table.

1. Create a copy of the I_CUSTOMER table in your own schema by using the following command:

CREATE TABLE N_CUSTOMER AS SELECT * FROM I_CUSTOMER;

2. Also create a table to store change logs (CUSTOMER_CHANGELOG) by using the following command:

CREATE TABLE CUSTOMER_CHANGELOG

(

cust_no NUMBER(5),

cust_name VARCHAR2(20),

contact VARCHAR2(20),

log_date DATE);

3. Create a database trigger with the following specification:

• fires AFTER an UPDATE on N_CUSTOMER table.

• fires if there is any change to cust_name or contact columns of the N_CUSTOMER table.

• fires for each row.

• inserts a first row: the affected cust_no column, the OLD values of the cust_name and contact columns and the current date into the table CUSTOMER_CHANGELOG.

• inserts a second row: the affected cust_no column, the NEW values of the cust_name and contact columns and the current date into the table CUSTOMER_CHANGELOG.

4. Test the trigger with the following specification:

• Go ahead and make a change to N_CUSTOMER table by issuing the following command:

UPDATE N_CUSTOMER

SET cust_name = 'Peter Davis', contact = 'Sam Bogdanovich'

WHERE cust_no = 2338;

5. Now, select all rows from the CUSTOMER_CHANGELOG table. This should display the old and new values of the changes you made due to firing of the trigger. Output all the rows of CUSTOMER_CHANGELOG table.

Question 4

Create a PL/SQL function called findtotalcarmodels to return the total number of cars belonging to a particular model. The function should have a single IN parameter as model_name. You should then use an explicit cursor to count the number of cars belonging to that car model and return the final count. You must NOT use any implicit cursors, table joins, subqueries, set operators, group functions or SQL functions (such as COUNT) to create this function.

Now, write ONE PL/SQL anonymous block that provides a report about car details.

The full specification to create the PL/SQL anonymous block is as follows:

• Using an explicit cursor, retrieve all car registration, cost and model name details (registration, cost & model_name) from the I_CAR table.

• If the cost of the car is less than or equal to $50,000, we determine car cost category as "Budget Car". If the car cost is between $50,000 and $100,000, the car cost category is "Standard Car". For all other cars costing more than $100,000; the car cost category is "Premium Car". Declare a local variable v_carcategory as VARCHAR2(40) to store car cost category.

• Call the function findtotalcarmodels to get the total number of cars belonging to the model name for the car and store them in a local variable named v_totalcars.

• Use an explicit cursor with a parameter that accepts car registration to find the most recent reservation made on the car. You will have to look at the date_reserved column from I_BOOKING table here. You cannot use the MAX function. Compare all the relevant dates to find the most recent one.

• Display a report showing car registration, car cost category, car model name, total number of cars belonging to that model and the most recent reservation made on that car.

• Finally, create an exception handler which fires when no rows are found. The exception handler should output the following message to the screen: "No rows found".

Important Notes:

• You must NOT use any implicit cursors, table joins, subqueries, set operators, group functions or SQL functions (such as COUNT) to create the PL/SQL function or the PL/SQL anonymous block.
• The PL/SQL anonymous block must be ONE block only. Do NOT write a block to perform each task of the specification above.

DBMS, Programming

  • Category:- DBMS
  • Reference No.:- M91564610
  • Price:- $45

Priced at Now at $45, Verified Solution

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