P h i

advertisement
Faculty of Information Technology
Department of MIS
Philadelphia University
Lecturer: Dr. Samir Tartir
Coordinator: Dr. Samir Tartir
Internal Examiner: Dr. Rasheed Al-Zubaidy
2014/2015
First Semester
Marking Scheme
Fundamentals of Databases – 761235
Second Exam
December 28th, 2014
Time: 50 minutes
Information for Candidates
1. This examination paper contains 4 questions totaling 20 marks
2. The marks for parts of questions are shown in round brackets.
Advice to Candidates
1. You should attempt all questions.
2. You should write your answers precisely, clearly and to the point.
I. Basic Notions
Objectives: The aim of the questions in this part is to evaluate the required minimal student knowledge and skills. Answers
in the pass category represent the minimum acceptable standard.
Question 1: [5 marks]
Assume you have the following two tables. Write the proper SQL statements for the questions that follow.
Column Name
Plate_Num
Year
Make
Model
Car
Date Type
Number
Number
Varchar2
Varchar2
Car _owner
Column Name Date Type
Owner_ID
Number
Owner_Name
Varchar2
Address
Varchar2
DOB
Date
Plate_Num
Number
Length
10
4
15
10
Length
10
15
20
10
Q1: Write the SQL to create the Car_Owner table, along with the needed constraints.
CREATE TABLE CAR_OWNER (
OWNER_ID NUMBER(10),
OWNER_NAME VARCHAR2(15),
ADDRESS VARCHAR2(20),
DOB DATE,
PLATE_NUM NUMBER(10),
PRIMARY KEY OWNER_ID,
FOREIGN KEY PLATE_NUM REFERENCES CAR;
);
Q2: Change the type of the "model" column in the Car table to varchar2 (15).
ALTER TABLE CAR MODIFY MODEL VARCHAR2(15);
Q3: Add a new attribute to the "car" table, name it "color" and give it a suitable data type.
ALTER TABLE CAR ADD COLOR VARCHAR2(10);
Q4: Change the name of the "car" table to have the name "vehicle".
ALTER TABLE CAR RENAME TO VEHICLE;
Q5: Drop the "vehicle" table.
DROP TABLE VEHICLE;
II. Familiar Knowledge
Question 2: [5 marks]
Convert the following EER Diagram for a university database to the corresponding tables.
Note: You must show PKs and FKs
Client
Name
email
Phone
Seller
Name
(FK: Client)
Lawyer
Buyer
Name
(FK: Client)
Employer
Agent
Name
Phone
Property
County
Lot No.
Address
Comm Rate
Email
Town
Mort Co
Emp. Address
Mentor
FK: Agent
Asking Price
Commercial
County
Lot No.
Town
FK: Property
Zoning Cat
Residential
County
Lot No.
Town
FK: Property
Bedrooms
AgentName
FK: Agent
SName
FK: Seller
BName
FK: Buyer
Bathrooms
Entities: 7*.25 (1.75) + Inheritance: 4*.5 (2) + 1-m 4* .5 (2) = 5.75
Question 3: [5 marks] Consider the following schema and write down relational algebra expressions
that satisfy the following queries.
Works
Emp_name
Company_name Salary
Lives
Employee_name Street City
Located_in
Company_name City
Manager
Ename
Manager_name
A) Find the names of employees who take a salary above 1000 JD.
Answer  πEmployee_name (σsalary>'1000'(works))
B) Find the names of the employees who do not work for company ’ABC’
Answer  πEmployee_name (σcompany_name<>'ABC'(works))
C) Find the names of the employees who don’t have a manager.
EmpWithMngr  πename (Manager)
AllEmps  πEmployee_name (Lives)
Answer  AllEmps – EmpWithMngr
D) Find the names, streets and cities of employees who work for company 'ABC' with a salary of
more than 10,000.
EmpsBigSal  σsalary>10000 & company_name='ABC' (works)
Answer  πEmployee_name, city, street (EmpsBigSal Lives)
E) Find the names of the employees who live and work in the same city.
Company  lives works
WorkLoc  Company company_name located_in
SameCity  σWorkLoc.city=Lives.city (WorkLoc)
Answer  πEmployee_name (SameCity)
III. Unfamiliar Knowledge
Objectives: The aim of questions in this part is to evaluate that the student has some basic knowledge of the key aspects of
the lecture material and can solve problems.
Question 4: [5 marks]
A club has hired you to create a database to store information about the club. Based on the following
requirements, design an EER conceptual schema.
1. The club has a number of locations throughout the city. Each location has a Location ID, and
Address, a description and a maximum capacity.
2. Each location has different areas. For example, weight areas, football fields, etc. Each area has an
Area ID, a type, a description and a size.
3. Events are held at the club, and the club tracks the Event ID, the event name, description, date,
time, as well as the Area ID where the event is being held. One event can be held across multiple
areas.
4. There are 2 types of events:
a. Sporting Events: Which have the name of the teams competing
b. Parties: Which have the name of the organizer, and the duration.
5. There are three categories of equipment in the club:
a. Bicycles, which have a bike ID, and color
b. Shoes, which have a shoe ID and size
c. Sports Equipment, which has an Equipment ID, and equipment type.
6. The club rents some equipment to the visitors. Each time the equipment is rented, the club records
the date and time.
Download