Practice Test Final
Practice Test Final
Large collection of files is called :__________________ b. Oracle 11g, g is for grid, I is for internet and c is for client c. BLOB is binary large object, CLOB is character large object (these are data types) d. The identifier of an entity will become the ________ of the new table. a. Foreign Key b. Main Attribute c. Primary key d. Identity Key e. The terms alternate key and candidate key mean the same thing. (T/F)
Part 2 : Short Answer Questions 1. In the context of database security, explain the concepts of Authentication and Authorisation
2. In your own words, define what is meant by the term database transaction. explain what the ACID properties are in RDBMS?
3. Foreign keys are normally designed to protect data in tables that are in a parent-child relationship. If a column in a table is declared to be a foreign key, what integrity checks will be placed on data in the two tables involved in the foreign key definition?
Ans: Values in the foreign key column(s) must exist in the corresponding columns of the parents primary or unique key that is being referenced. NULL values are an exception to this rule. Key values of rows in the parent table that have are dependent foreign key values cannot be updated or deleted.
4. Write an SQL statement to calculate the number of hours between todays date (SYSDATE) and May 1, 2013.
Part 3: Explanation Questions 1. The following table called Employees records employees membership of a particular team. employeeID membership ---------- ---------E1 AshForce E2 Vallance E3 Bass E4 Mission E5 Bass E6 NULL The following table called Teams records the budget of each team mname budget --------- --------------------Bass 675.00 Vallance 348.00 Mission 250.00 Ashforce NULL a) Showing any working, determine what output is produced by each of the following queries:Query1: SELECT distinct t.* FROM employees as e RIGHT JOIN teams as t ON e.membership = t.mname Query2: SELECT SUM(budget) as totalbudget, Mname FROM employees as e INNER JOIN teams as t ON e.membership = t.mname GROUP BY Mname
Page 2
Query3: SELECT F.EmployeeID, S.EmployeeID, F.membership FROM Employees F JOIN Employees S ON F.Membership = S.membership WHERE F.EmployeeID < S.EmployeeID ORDER BY F.EmployeeID, S.EmployeeID; b) Describe the different types of JOINS present in the above queries.
Q2. Using a suitable diagram and any appropriate examples, describe the ANSI 3level database architecture and how a database form relates to that model. In particular, at what level would a form sit within the three-level architecture of a typical database system? What other (non-form) techniques or interfaces are available that operate at the same level of this architecture and provide a similar function as a form (hint: think programmatic interfaces)?
Q3. What is normalisation? (5 marks) b) Use the following form to complete first, second and third normal forms:
Page 3
c) Use completed third normal form to generate database model with correct relationships between entities
Ans:
Q4. Draw an Enhanced Entity-Relationship Diagram (EERD) using UML notation for the following situation. Show the relevant entities, attributes, primary keys, relationships, participation constraints, disjoint constraints, and cardinality constraints. A nonprofit organization, HELP, depends on three different types of persons for its successful operation: employees, volunteers, and donors. The organization keeps the following data about each person: S.I.N., name (composed of first and last name), e-mail, and up to three phone numbers (minimum one phone
Page 4
number). Employees may be contractors or permanent employees (never both). Contractors are paid per hour; permanent employees have salaries. A volunteer has at least one skill, but potentially several skills that can be used by the organization. Skills have generic descriptions, for example: writing, driving, and public speaking. A donor is a person who has donated one or more items to the organization. A donated item may be donated by unspecified person, one or many donors. When an item is donated, the organization records its description and value. An employee may be a volunteer and/or a donor.
Q5. Vehicle Rental The following tables: Vehicle, Reservation, and Client are used by Vehicle Reservation System. Vehicle Rental System has the following business rules: (1) A vehicle may be rented for a period of one day or many days, (2) A vehicle can be rented only once per day, and (3) A rental is charged for a full day, even if the car is rented for a few hours.
Vehicle
V_Id V_Make Cost_per_day
Reservation
Res_Id Start_date End_date Client_Id V_Id
Client
Client_Id DOB C_Name C_Address C_City
a.Using the tables above, write an SQL statement to list all vehicles (vehicle ids) and their total charges for rentals. The Total Revenue is calculated as costper-day x number of days rented. Round up the number of days, and display the total revenue with two decimal places. For the vehicles without rentals, the total charge should be 0.00. List the results from the highest revenue to the lowest revenue. Here is a sample listing: (3 marks) V_ID 9090 10099 8090 9095 Total Revenue 600.00 149.00 0.00 0.00
b. Write SQL statement to increase the cost per day by 5% for all cars which have the cost per day less than the average cost of all cars in the vehicle table. (2 marks)
Page 5
Q6. The table EXAM has the following data EXAM_ID A1 A2 A3 A4 A5 MARK 100 NULL 100 100 100
queries? Show calculations. SELECT AVG(NVL(MARK,0)) FROM EXAM; result ______________ SELECT AVG(MARK) FROM EXAM;
result _______________
Hint: the NVL function lets you substitute a value when a null value is encountered.
Q7. What is the result (text displayed) after the execution of the following PL/SQL code? DECLARE l_variable VARCHAR2 (10) := 'Logic'; l_fixed CHAR (10) := 'Logic'; BEGIN IF l_variable = l_fixed THEN DBMS_OUTPUT.put_line ('Equal'); ELSE DBMS_OUTPUT.put_line ('Not Equal'); END IF; END; ________________________________?
Page 6