0% found this document useful (0 votes)
71 views

CSCI335 SampleFinalExam

Uploaded by

yaacoubsalame85
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views

CSCI335 SampleFinalExam

Uploaded by

yaacoubsalame85
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

CSCI335 Sample Final Exam Fall 2021 – 2022

Lebanese International University


School of Arts and Sciences - Department of Computer Science

Course Name : Database Systems Course Code : CSCI335


Date Section : All Sections
Instructor : Time : 2:00-4:00
Auditorium : Seat Number :

Number of pages :7 Allowed Time : 120 minutes


Documents : Calculators :

Problem# Grade Total Grade


Problem1 20
Problem2 30
Problem3 20
Problem4 30
/100

Good Luck

Page 1 of 7
CSCI335 Sample Final Exam Fall 2021 – 2022

Problem 1: T/F (20 points)

1. An aggregate function is a function where the values of multiple rows are grouped
together as input on certain criteria to form a single value of more significant
meaning such as average , total and product
2. The Deletion anomaly is when we delete one tuple, other tuples will be deleted as
well.
3. The count() function returns the number of columns in a relation
4. In order for a table to be in 1NF, there must not be multi-valued attributes.
5. In 2NF, we eliminate all Hidden Dependencies.
6. The Insert anomaly means that when we insert a new data, a lot of tuples need to
be updated as well.
7. A table can be in 3NF, even if it is not in 1NF.
8. If a relation is in 2NF, then it is also in 1NF.
9. Not being able to insert data because other data is required is an example of an
update anomaly.
10.All the attributes found in the “GROUP BY” clause should be also found in the
SELECT clause.

Page 2 of 7
CSCI335 Sample Final Exam Fall 2021 – 2022

Problem 2: MCQ (30 pts)


1. In the __________ normal form, a composite attribute is converted to individual attributes.
a. First
b. Second
c. Third
d. Fourth
2. The following WHERE Clause: “WHERE price IN (20, 30, 40)” is equivalent to:
a. WHERE price= 20 and price = 30 and price = 40
b. WHERE price >20 and price<40
c. WHERE price= 20 or price = 30 or price = 40
d. WHERE price >=20 and price<=40
3. Consider the table Computers ( ID, Company, Price, Manufacturer) Which of the following queries will
not produce any error:
a. Select avg(price)
From Computers
Group By Company
b. Select Company, avg(price)
From Computers
Group By Company
c. Select ID, avg(price)
From Computers
Group By Company
d. All of the above
4. Assume that we have a table with an attribute called price, and we need to display the price ordered
from the highest to the lowest. Which of the following ORDER BY clauses will be used:
a. ORDER BY Price DECREASING
b. ORDER BY Price
c. ORDER BY Price DESC
d. ORDER BY Price DECR
5. The __________ Clause is used to specify selection condition on groups:
a. WHERE
b. HAVING
c. GROUP BY
d. ORDER BY
6. An attribute is a __________ in a relation.
a. Row
a. Column
b. Value
c. Tuple
7. Related fields in a database are grouped to form a
a. Data file
a. Data record
b. Menu
Page 3 of 7
CSCI335 Sample Final Exam Fall 2021 – 2022

c. Bank
8. The primary key is selected from the:
a. Composite keys
b. Determinants
c. Candidate keys
d. Foreign keys
9. To get the number of returned tuples from a query, which aggregate function we use?

a. Count
b. max
c. sum
d. We can use all of the above
10. You can add a row using SQL in a database with which of the following?
a. ADD
b. CREATE
c. INSERT
d. MAKE

Page 4 of 7
CSCI335 Sample Final Exam Fall 2021 – 2022

Problem 3: Normalization (20 pts)


Consider the following table:

STU_NUM (STU_LNAME, STU_MAJOR)

DEPT_CODE (DEPT_NAME, DEPT_PHONE)

1) The table is susceptible to anomalies. Provide examples of insertion, deletion, and update anomalies

2) Describe and illustrate the process of normalizing the table into 3NF

Page 5 of 7
CSCI335 Sample Final Exam Fall 2021 – 2022

Problem 4: SQL Queries(30 pts)


Consider the following Relational schema and Relations instances.

Patient (ID:char(9), p_name:varchar(25), City: varchar(50))

Prescription (Patient_ID:char(9), Medicine_code:char(5), Clinic:varchar(25))

Medicine (code:char(5), m_name:varchar, Ingredients:varchar, Price:float )

Patient Prescription

ID P_name City Patient_ID Medicine_code Clinic

112233445 Adam Beirut 112233445 Nx306 Well Nutrition

998877665 Bob Saida 112233445 Pa003 Healthy Clinic

556677889 Sara Zahle 998877665 Pa003 Safe Clinic

443322445 Eve Tyre 443322445 Ad500 Safe Clinic

443322445 Nx306 Well Nutrition

Medicine

code M_name Ingredients Price

Pa003 Panadol Potassium, Paracetamol, Starch 5.5

Nx306 Nexume Magnesium, Polysorbate, Glyceryl 20.0

Ad500 Adol Acetaminophen, Paracetamol 3.0

Ap800 Aspirin Acetysalicylic Acid, Starch 8.55

Write SQL queries that will do the following:

1. List the name and the ID of all patients

2. List the price of Medicine called Nexume

3. Find the names of patients who have at least one prescription.

Page 6 of 7
CSCI335 Sample Final Exam Fall 2021 – 2022

4. Find the names of patients who have a prescription that contains the medicine called Panadol.

5. Find the average price of medicines

6. Find total price of medicines prescribed for a patient called Adam.

7. Find the names of the patients who have prescriptions from the ‘Well Nutrition’ clinic

8. Find the maximum price of a medicine

9. Find the name of the medicine(s) that have the lowest price

10. Find the name(s) of patient(s) who have more than one prescription

11. Find all the information about all medicines sorted in the ascending order of price.

12. Find the name of all medicines that have an ingredient called ‘paracetamol’

13. Find the name of all patients whose ID ends with ‘445’

14. Add new medicine to the database

15. Change the price of ‘Panadol’ medicine to 4

Page 7 of 7

You might also like