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

SQL – Trial exam

Question 1 (15 points)


Determine of each of the following statements if this is TRUE or FALSE.

In case it is FALSE, also write WHY you think it is false.

a) To remove a table from a database, you should use the DROP statement

b) The SELECT statement is part of the DDL from SQL

c) The CREATE TABLE statement is part of the DML from SQL

d) Aggegate functions, like COUNT, have to be used together with a GROUP BY statement.

e) The referential integrity states that a foreign key should always refer to an existing primary
key

f) If a subselect returns NULL(s) in the output set, you have to use IN as operator before the
subselect in the WHERE statement.

g) It is not allowed to do computations in a WHERE statement

h) The SQL standard for INNER JOIN states that the JOIN condition should be in the FROM
statement.

i) Suppose that A and B are mathematical sets, then |A X B| = |A| . |B|, where . is the
multiplication operator, and X the Cartesian product operator.

j) If ‘name’ is a column of a table, then ‘name = NULL’ is not a valid expression in a WHERE
statement.

Page 1 of 6
SQL – Trial exam

Question 2 (10 points)

Question 2.1 (5 points)


Copy the truth table below on your lined paper, and complete the table.

𝑃 𝑄 ¬𝑄 𝑃 ∨ ¬𝑄 ¬𝑃 ¬𝑃 ∧ ¬𝑄 (𝑃 ∨ ¬𝑄) ∧ (¬𝑃 ∧ ¬𝑄)


0 0
0 1
1 0
1 1

Question 2.2 (5 points)


Use the following sets fort his question:

𝐴 = {1, 2, 3, 4, 5, 6} 𝐵 = {0, 3}
𝐶 = {𝑎, {𝑏, 𝑐}, {𝑎, 𝑑, 𝑒}} 𝐷 = {𝑝, 𝑞}
Determine for each of the following statements if this is TRUE or FALSE.

a) A ⊂ B

b) | C | = 5

c) {0} ∈ B

d) |A x D| = 8

e) {(0, q)} ∈ B x D

Page 2 of 6
SQL – Trial exam

Question 3 (25 points)

Use for this question the HoF database shown in the appendix

Clearly indicate the result of the following queries (show column names, values and order):

a) SELECT gamecode
FROM games
ORDER BY year;

b) SELECT playercode, country


FROM players
WHERE country LIKE '%N%'
ORDER BY name;

c) SELECT gamecode, min(score) AS minimum, count(*) AS number


FROM scores
GROUP BY gamecode
HAVING count(*) > 1
ORDER BY gamecode;

d) SELECT DISTINCT name, country


FROM players
ORDER BY country DESC;

e) SELECT gamecode, year


FROM games
WHERE alternative IN ( SELECT consolecode
FROM consoles
WHERE sold > 100 )
ORDER BY year DESC;

Page 3 of 6
SQL – Trial exam

Question 4 (20 points)


Use for this question the HoF database shown in the appendix

Write the query that will show the requested information, and will match the shown results.

Check carefully the column names and the order.

a) Show the names of the players that do not have any scores

b) Show from the players with a known birth year and who have scored, the name, gamecode
and age.

c) Show the name, gamecode and the name of the console for games that are played standard
on a console.

d) Show all unique codes of games, for which a player from England or Russia has scored.

e) Show for all games that do not have their origin in the USA, the gamecode and consolecodes.
Sort the result on game, and then on consolecode.

Question 5 (20 points)

Use for this question the HoF database shown in the appendix

Indicate exactly what the result will be of the following queries. If the query will not work, indicate
why not, if it does work indicate everything that might change.
a) UPDATE consoles
SET consolecode ='PS4'
WHERE consolecode = 'PS3';

b) DELETE FROM players


WHERE playercode = 'ZM' AND playercode = 'PS';

c) UPDATE consoles
SET consolecode ='N3DS2'
WHERE consolecode = 'N3DS';

d) UPDATE players
SET name = 'G-FAILES'
WHERE playercode = 'GF';

Page 4 of 6
SQL – Trial exam

Appendix: HoF database


HoF database tables and records

Page 5 of 6
SQL – Trial exam

HoF database diagram

Page 6 of 6

You might also like