You are on page 1of 4

REGENT UNIVERSITY

COLLEGE OF SCIENCE AND TECHNOLOGY

FACULTY OF ENGINEERING, COMPUTING AND


ALLIED SCIENCES

EXAMINATION PAPER

END OF FIRST SEMESTER EXAMINATION

SIIS2563: DATABASE SYSTEM II

Date: December, 2017

Time Allowed: 2 Hrs 30 min

MATERIAL PROVIDED: BASIC SQL SYNTAX

INSTRUCTION: Answer all Questions

LECTURER: SAMUEL CHRIS QUIST


Answer all Questions ProspectiveStudent table in the Admissions_DB Schema? Explain your
answer. [3 marks]
Question 1
v. Which of the Users would be responsible for adding new Asset_Category
a. Explain the following terms as used in database Administration. in the Asset_DB schema? Explain your Answer. [3 marks]
i. Global privilege. ii. Schema Object privilege. iii. Schema privilege
vi. Which of the Users can update a record in the Asset_Category table in th
[6 marks]
Asset_DB? Explain your answer. [3 marks]
b. Given that there are only three users A, B and C and three database
schemas Asset_DB, Hotel_DB and Admissions_DB on your database vii. Is it possible to delete a staff record from the Staff table in the Hotel_DB?
server with user A granted global privileges of SELECT and UPDATE. Explain your answer. [3 marks]
User B granted Schemata privilege to INSERT, UPDATE and DELETE on
viii. Which of the Users would be responsible for Displaying Records from
the Hotel_DB. User C have been granted the following Schema Object
the Room_Reservation object schema in the Hotel_DB? Explain your answer.
Privileges within the ASSET_DB Schemata. (No other assumptions).
[3 marks]
SELECT UPDATE INSERT DELETE
ASSET_CATEGORY Y N Y N
Question 2
ASSET_MAIN N N Y N
STAFF Y N N N ESTATE_AGENT(ea_num, ea_name, ea_address, ea_email)
DEPARTMENT N N Y N PROPERTY_CATEGORY(cat_num, cat_name)
MAINTENANCE N N Y Y CUSTOMER(cusId, name, email, address, occupation, income_level)
i. Is it possible to insert a new staff data into the Staff table in the Asset_DB PROPERTY(propSerialNum, cat_num, description, date_listed, num_room,
schema? Explain your answer. [3 marks] num_washrooms, suburb, region, price, year_completed, ea_num)
ii. Is it possible to delete a customer record from the Customer Table in the VIEW(vSerial, vDate, propSerialNum, cusId)
Hotel_DB? Explain your answer. [3 marks] SALE(saleNum, propSerialNum, saleDate, paymentMethod, cusId)
iii. Which of the users would be responsible for Updating Staff details in the SALES_HISTORY(saleNum, propSerialNum, description, num_rooms,
Asset_DB? Explain your answer. [3 marks] saleDate, paymentMethod, cusId, customer_name, occupation)
iv. Which of the users would be responsible for deleting data from the
Using SQL Statement l. Display the suburbs and their respective region with more than 10 units of 2
or more bedrooms properties listed in that suburb, arrange your output by the
a. Create a Database Named EstateManagementDB. [2 marks]
Regions in alphabetical order. [5 marks]
b. Create the tables Customer, Property and Sale
[10 marks] m. Increase the price of all property listing in the “Dansoman” suburb in the
c. Insert 2 records each into the Property and Sale tables. [4 marks] Greater Accra Region by 15%, once that property has been viewed more than
d. There is an omission of an Attribute in the Property schema or table; 25 times. [5 marks]
include the attribute “OtherInfo” on the Property table. [3 marks]
n. To populate the Sales_History table with the Respective Data items from
e. Display all customers who are lecturers with an income level more than
the tables for all sales done for the current date. [5 marks]
GHS50, 000.00 per annum. [4 marks]
o. Write a php script to capture data from a web form and insert it into the
f. Display the details of all Properties sold in the same year they were listed
Property table in the database created on a server named “Leonard”, with a
and the date the property was sold [5 marks]
user name and password of “Good”, “luck” respectively. [6 marks]
g. Display the Property category Name and the total cost of all the
Properties in that Category. [4 marks]

h. Display each month the number of properties viewed for the year 2017
. [4 marks]
i. Display Each Agent (Name) and the Number properties he/she has listed
in the Ashanti Region. [4 marks]
j. Display each Region and Average cost of 3-bed room properties.
[4 marks]
k. Display all customers (Name, Email, Occupation and Income_Level), the
number of times they have ever viewed a property for customers who have
never bought any property before. [5 marks]
BASIC SQL SYNTAX

SELECT [DISTINCT | ALL]


{* | [columnExprn [AS newName]] [,...] }
FROM TableName [alias] [, ...]
[WHERE condition]
[GROUP BY columnList]
[HAVING condition]
[ORDER BY columnList]

INSERT INTO TableName [ (columnList) ]


VALUES (dataValueList)

UPDATE TableName
SET columnName1 = dataValue1
[, columnName2 = dataValue2...]
[WHERE searchCondition]

DELETE FROM TableName


[WHERE searchCondition]

CREATE TABLE TableName


{(columnName dataType [NOT NULL] [UNIQUE]
[DEFAULT defaultOption][,...]}
[PRIMARY KEY (listOfColumns),]
{[UNIQUE (listOfColumns),] […,]}
{[FOREIGN KEY (listOfFKColumns)
REFERENCES ParentTableName [(listOfCKColumns)],
[ON UPDATE referentialAction]
[ON DELETE referentialAction ]] [,…]}

DESC TABLE tablename.

DROP TABLE tablename;

USE databasename;

ALTER TABLE tblname {ADD fieldname datatype [NOT NULL] [UNIQUE]


[DEFAULT defaultOption] │MODIFY fieldname dataType [NOT NULL]
[UNIQUE] [DEFAULT defaultOption]│DROP fieldname };

CREATE DATABASE IF NOT EXISTS dbname;

You might also like