Uploaded by Mansoor Alzaabi

final exam sample

advertisement
American University of Sharjah
School of Engineering
Department of Computer Engineering
P. O. Box 26666
Sharjah, UAE
Instructor: Omar Arif
Office: ESB-2178
Phone: 971-6-515 4821
e-mail: oarif@aus.edu
Semester: Fall 2022
Failure to put your name and ID will result in a
2-point deduction from you grade.
Name: ____________________
ID :
____________________
This is a just a sample. Actual exam questions
and question types can be substantially
different from the questions in the sample.
CMP320 – Final Exam
Time: 120 Minutes
Total Points: 60
You can have one handwritten A4 size cheat sheet
Course Learning Outcomes:
1. Describe the different components and benefits of a commercial-grade database system.
2. Model data requirements using entity-relationship (ER) and extended entity-relationship (EER)
diagrams.
3. Map ER and EER diagrams into relational schema.
4. Express database queries using relational algebra and relational calculus.
5. Write SQL statements to create queries and modify database schemas.
6. Understand functional dependences and their use in defining normal forms up to 3rd and BCNF
normal forms.
7. Understand some advanced concepts in database systems including indexing, transaction processing,
and crash recovery algorithms.
8. Design, implement and run a database application using a commercial grade (Oracle for example)
database management system platform.
Registeration # __________________________
1
2
3
4
5
6
7
8
9
10
11
12
Lecture
Introduction to DB
DB system concepts and architecture
The relational data model and constraints
Basic SQL
Complex SQL
More SQL
ER Model
EER Model
ER/EER to relational Model
Relational Algebra and relational calculus
Database normalization
Adv Topics
Weightage in Final Exam
≈ 10
0
≈ 10
0
0
0
≈ 10
≈ 10
≈ 10
≈ 10
Question 1:
CLO1: Describe the different components and benefits of a commercial-grade database system.
Lecture 1 and lecture 2
Sample Questions:
1. Define the following terms: data, database, DBMS, database system, program-data independence,
DBA, end user, meta-data, and transaction-processing application.
2. Discuss the main characteristics of the database approach [slide 12-16 of lecture 1]
3. What are the different types of database users [slide 21 onwards of lecture 1]
4. What are the functionalities provided by the DBMS [slide 6-7 lecture 1]
5. What are the advantages of database approach [slide 24]
6. Define the following terms: data model, database schema, database state, conceptual schema,
external schema, data independence, DDL, DML, client/server architecture, three-tier architecture,
7. What is the difference between a database schema and a database state?
8. What is the difference between the two-tier and three-tier client/server architectures
Question 2:
CLO3:Map ER and EER diagrams into relational schema.
Lecture 9
Sample Questions:
1. Map the UNIVERSITY database schema shown below into a relational database schema.
P a g e 2 of 10
Registeration # __________________________
P a g e 3 of 10
Registeration # __________________________
2. Map the EER diagram below for a car dealer to relational schema using option 8A.
P a g e 4 of 10
Registeration # __________________________
Question 3:
CLO4: Express database queries using relational algebra and relational calculus.
1.
Retrieve the names of all employees in department 5 who work more than 10 hours per
week on the
ProductX project.
2.
List the names of all employees who have a dependent with the same first name as
themselves.
P a g e 5 of 10
Registeration # __________________________
3.
Find the names of all employees who are directly supervised by ‘Franklin Wong’.
4.
Retrieve the names of all employees who do not work on any project.
5.
Find the names and addresses of all employees who work on at least one project located in
Houston but whose department has no location in Houston.
6.
List the last names of all department managers who have no dependents
7. Consider the following six relations for an order-processing database application in a
company:
CUSTOMER(Cust#, Cname, City)
ORDER(Order#, Odate, Cust#, Ord_amt)
ORDER_ITEM(Order#, Item#, Qty)
ITEM(Item#, Unit_price)
SHIPMENT(Order#, Warehouse#, Ship_date)
WAREHOUSE(Warehouse#, City)
P a g e 6 of 10
Registeration # __________________________
a) List the Order# and Ship_date for all orders shipped from Warehouse# W2.
b) List the WAREHOUSE information from which the CUSTOMER named Jose Lopez was supplied his
orders. Produce a listing: Order#, Warehouse#.
c) List the orders that were not shipped within 30 days of ordering.
Question 4:
CLO5: Write SQL statements to create queries and modify database schemas.
Lecture 4 and Lecture 5
Question 5:
CLO6:Understand functional dependences and their use in defining normal forms up to 3rd and BCNF
normal forms.
Lecture 11
Question similar to Quiz 3 and participation quiz 3 and 4
1. Below is a table that a dentist uses to keep track of her work on her patients' teeth. Each patient
has a unique phone number. Assume, a patient can visit the dentist only once in a single day
(phone and visit_date are primary key). Each diagnosis has fixed charge that is billed to the
patient. Insurance company has a unique phone number.
P a g e 7 of 10
Registeration # __________________________
Patient(name, phone, insurance_number, insurance_name, insurance_ph,
visit_date, which_tooth, symptoms, diagnosis, amount_billed)
a) Identify all the functional dependencies
name
phone
insurance_number
insurance
_name
insurance
_ph
visit
_date
which_
tooth
symptoms
diagnosis
amount_b
illed
FD1
FD2
FD3
FD4
b) Convert the table into a database with all tables in 3NF
2NF
Patient01(phone, insurance_name, insurance_ph, visit_date, which_tooth,
symptoms, diagnosis, amount_billed)
Patient02(name, phone, insurance_number)
3NF
Patient01a(phone, insurance_name, visit_date, which_tooth, symptoms,
diagnosis)
Patient01b(insurance_name, insurance_ph)
Patient01c(diagnosis, amount_billed)
Patient02(name, phone, insurance_number)
P a g e 8 of 10
Registeration # __________________________
Question 6:
CLO7:Understand some advanced concepts in database systems including indexing, transaction
processing.
Lecture 12
Sample Questions:
1. A file has r = 20,000 STUDENT records of fixed length. Each record has the following fields:
Name (30 bytes), Ssn (9 bytes), Address (40 bytes), PHONE (10 bytes), Birth_date (8 bytes), Sex (1
byte), Major_dept_code (4 bytes), Minor_dept_code (4 bytes), Class_code (4 bytes, integer), and
Degree_program (3 bytes). An additional byte is used as a deletion marker. Let block size
B=512 bytes
1. Calculate the record size R in bytes.
2. Calculate the blocking factor bfr and the number of file blocks b, assuming an
unspanned organization.
3. Calculate the average number of block accesses to find a record by doing a linear
search on the file if (i) the record is found (ii) the record is not found
4. Assume that the file is ordered by Ssn; by doing a binary search, the numer of block
access.
Calculating record size:
1. R = 30 + 9 + 40 + 10 + 8 + 1 + 4 + 4 + 4 + 3 + 1 =114 bytes
2. bfr = floor(B/R) = floor(512/114) = 4 records per block
b= ceil(r/brf) = 5000 blocks
3. (i) 2500 block access, (ii) 5000 block access
4. log ! 5000
2. Indexing Example. Consider the file of Example 1 from lecture slides with r =
300,000 fixed-length records of size R = 100 bytes stored on a disk with block size B
= 4,096 bytes. The file has b = 7,500 blocks, as calculated in Example 1. Suppose we
want to search for a record with a specific value for the secondary key—a
nonordering key field of the file that is V = 9 bytes long. Without the secondary
index, to do a linear search on the file would require b/2 = 7,500/2 = 3,750 block
accesses on the average. Suppose that we con- struct a secondary index on that
nonordering key field of the file. As in Example 1, a block pointer is P = 6 bytes long,
so each index entry is Ri = (9 + 6) = 15 bytes, and the blocking factor for the index is
bfri = ⎣(B/Ri)⎦ = ⎣(4,096/15)⎦ = 273 index entries per block. In a dense secondary
index such as this, the total number of index entries ri is equal to the number of
records in the data file, which is 300,000. The number of blocks needed for the index
is hence bi = ⎡(ri/bfri)⎤ = ⎡(300,000/273)⎤ = 1,099 blocks.
P a g e 9 of 10
Registeration # __________________________
A binary search on this secondary index needs ⎡(log2 bi)⎤ = ⎡(log21,099)⎤ = 11 block accesses.
To search for a record using the index, we need an additional block access to the data file for
a total of 11 + 1 = 12 block accesses—a vast improvement over the 3,750 block accesses
needed on the average for a linear search, but slightly worse than the 6 block accesses
required for the primary index. This difference arose because the primary index was
nondense and hence shorter, with only 28 blocks in length as opposed to the 1,099 blocks
dense index here.
3. Suppose that the dense secondary index of previous Example is converted into a multilevel
index. We calculated the index blocking factor bfri = 273 index entries per block, which is
also the fan-out fo for the multilevel index; the number of first-level blocks b1 = 1,099 blocks
was also calculated. The number of second-level blocks will be b2 = ⎡(b1/fo)⎤ =
⎡(1,099/273)⎤ = 5 blocks, and the number of third- level blocks will be b3 = ⎡(b2/fo)⎤ =
⎡(5/273)⎤ = 1 block. Hence, the third level is the top level of the index, and t = 3. To access a
record by searching the multilevel index, we must access one block at each level plus one
block from the data file, so we need t + 1 = 3 + 1 = 4 block accesses. Compare this to Example
3, where 12 block accesses were needed when a single-level index and binary search were
used.
P a g e 10 of 10
Download