Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Information Systems and Networks (EM6043)

December 18th 2019 - Exam A

Student Name Student ID Teamwork (yes/no) Groupname

This is the first part of the exam and should be returned within 30 minutes.

1 Multiple choice questions (1 point each)


Check the box on the left of the correct answer. There is exactly one correct answer for each question.

Given the following E/R diagram:

1 Entity set B cannot be empty


2 Entity set A and B must have the same number of entities
! One entity set can have more entities than the other
3 Entity set A cannot be empty

If table A has 7 rows and table B has 5 rows, any cartesian product between A and B would produce:
1 at most 13 rows
2 exactly 13 rows
3 at most 35 rows
! exactly 35 rows
The NULL value:
1 Can appear only one time in a table
! Can be used for attributes whose value is unknown
2 Can’t be used in tables
3 Can’t be used in queries

The union operator of relational algebra fails if:


1 One of the involved tables is empty
2 One of the involved tables includes NULL values
3 The two tables have a different number of rows
! The two tables have a different number of columns
A primary key:

1 Is always single attribute of a relation and must be unique within such relation
2 Is always single attribute of a relation and must be unique within all the relations in the database
! Can include more than one attribute of a relation and must be unique within such relation
3 Can include more than one attribute of a relation and must be unique within all the relations in the database

1
2 SQL Language questions (2 points each)
A database used to model a e-commerce website is made up of the following tables:
userid name city userid prodid quantity
prodid description price
101 ”Mario Rossi” Milan 101 11 1
10 TV LCD Samsung 450.0
102 ”Giovanni Verdi” Venice 101 12 2
11 LCD TV LG 400.0
103 ”John Smith” Milano 102 10 2
12 HDMI cable 10.90
104 ”Piero Boscolo” Chioggia 103 12 10
products users basket
For each of the following queries write the output table (using the space below each query):
SELECT count(price) AS total FROM products, users, basket
total
48
SELECT p.description FROM basket AS b, products AS p WHERE p.prodid=b.prodid AND p.price<500
description
TV LCD Samsung
HDMI cable
LCD TV LG
HDMI cable
SELECT a.description FROM products AS a, products AS b WHERE a.price=50+b.price
description
TV LCD Samsung

SELECT p.description, count(*) as num FROM products AS p, basket AS b


WHERE p.prodid=b.prodid and p.description LIKE ’%TV%’
GROUP BY p.description
description num
LCD TV LG 1
TV LCD Samsung 1
SELECT p.description FROM basket AS b, products AS p
WHERE p.prodid=b.prodid AND p.price>=(SELECT MAX(price) FROM products)
description
TV LCD Samsung

2
Student Name Student ID Teamwork (yes/no) Groupname

Use a E/R diagram to model the described scenario and translate it to suitable relation schemas.
Write down as additional notes all the information that you think could be useful to better describe the solution. The
student must submit this second part within 60 minutes.

The dean of your University asks you to design a database to store data about courses and exams. He lets you complete
freedom, however he strictly requires that the following data can be extracted from the database using one or more
queries:
• Given an exam, find all the exams that must be passed before attempting it

• Given an exam and a year, find the average mark obtained by all the students that passed the exam that year
• Given an exam and a student ID, find how many times (if any) the student failed the exam
• Given an exam and a city, find the average mark obtained for that exam by students from that city
Note that you are not required to write the queries to extract such data ! However an expert CIO must be able to
write them. Thus you have to check that the critical questions can be answered using your data organization.

Exams(examId, description)
Students(studentId, name, city)
comesBefore(mustBePassedExamId, toAttemptExamId)
hasAttempted(attemptedExamId, attemptingStudentId, date, grade, accepted)

You might also like