0% found this document useful (0 votes)
16 views7 pages

Exam Dbms

The document outlines a series of SQL-related questions and tasks, including writing queries to retrieve specific information from a database schema involving movies, directors, and writers. It also includes questions about functional dependencies, ER diagrams, and relational algebra expressions. Additionally, it addresses database privileges and transaction interleaving scenarios.

Uploaded by

Anusha Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Exam Dbms

The document outlines a series of SQL-related questions and tasks, including writing queries to retrieve specific information from a database schema involving movies, directors, and writers. It also includes questions about functional dependencies, ER diagrams, and relational algebra expressions. Additionally, it addresses database privileges and transaction interleaving scenarios.

Uploaded by

Anusha Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Information

v3 (latest)

Given the following database schema:


create table movie(
title text,
year integer,
runtime integer,
genre text,
primary key (title, year)
);

create table person (


id integer primary key,
firstname text,
lastname text,
yearborn integer
);

create table director(


id integer references person (id),
title text,
year integer,
foreign key (title, year) references movie (title, year),
primary key (title, year)
);

create table writer(


id integer references person (id),
title text,
year integer,
foreign key (title, year) references movie (title, year),
primary key (id, title, year)
);

Question 7

Not answered
v5 (latest)

Write an SQL query that lists the firstname and lastname of all persons who have directed a movie in the 'crime' genre but never directed a movie
in the 'comedy' genre. The query result should have two columns, which are the firstname and lastname.
Your query must be runnable. You can use psql to test your SQL query for syntactic correctness and correctness wrt the database schema.
(Max 6 marks.)
Question 8

Not answered
v3 (latest)

Write an SQL query that lists the firstname and lastname of all persons who have written a movie, but only together with other writers (i.e., have
never been the only writer on any movie) together with the number of movies that they have written. The query result should have three columns:
firstname, lastname, and the number of movies written.
Your query must be runnable. You can use psql to test your SQL query for syntactic correctness and correctness wrt the database schema.
(Max 4 marks.)
Question 9

Not answered
v3 (latest)

Consider the following ER diagram:

Correctly complete each of the following statements about the ER model described by the diagram:

• Each crew has home city.

• Each city is the home of crew.

• Each flight has ground crew travelling on it.

• An air crew person can operate flights on the same date.

• The correct way of translating the "depart" relationship into a relational schema using the foreign key approach is:

• The correct translation of the "depart" relationship into a relational schema using the cross-reference approach is:
.

• Each city that has at least one arriving flight must also have at least one departing flight: .

• Each city that has at least one departing flight must also have at least one arriving flight: .

Note: Selecting an incorrect alternative for one of the statements may result in a lower total mark than not selecting any alternative for that
statement. (Max 8 marks.)
Question 10

Not answered
v2 (latest)

A group of sports fans are designing a database to record their teams' matches. It includes the following table:
LINEUP(Team, Opponent, Day, Player, Number, Position)

Each row in the table records the position of a player in the starting lineup of the team in one match.
The following rules apply to the relation:

• Each team can play at most one match in a day.


• A player can only play for one team at a time.
• A player's number is unique among all players currently in the team. The player will keep the same number at all times they are with the
team, but if a player leaves the team, another player may take over the number, and if the player goes to another team, they may have a
different number in that team.
• Each player in the team's starting lineup for a match plays one position for that match, and the positions of all players in the lineup are
distinct.
• A player can play in different positions in different matches.

Based on these rules, select among the following functional dependencies all that should apply to the LINEUP relation. (Max 6 marks.)

{Team} → Opponent

{Team} → Day

{Team} → {Player, Number}

{Team, Opponent} → Day

{Team, Day} → Opponent

{Day, Opponent} → Team

{Player} → Number

{Player} → {Number, Position}

{Team,Player} → Number

{Team,Player} → {Number, Position}

{Number} → Player

{Number} → {Player, Team}

{Number, Team} → Player

{Day,Team,Player} → Number

{Day,Team,Player} → {Number, Position}

{Day,Team,Number} → Player

{Day,Team,Number} → {Player, Position}


Question 11

Not answered
v3 (latest)

Let R = { A, B, C, D, E } be a relation schema with the set of FDs Σ = { {B, D, E} → A, {B, D, A} → E, {B, C, D} → A, {C, D} → E }.
Select from the following relations a set that constitutes a BCNF decomposition of the relation. The decomposition should be lossless, but it
does not need to be dependency-preserving. There can be more than one correct answer, in the sense that the relation can have more than one
BCNF decomposition: You should select all relations included in one decomposition, and no more. Note that the order in which attributes are
listed in a relation does not matter. (Max 6 marks.)

R1 = {A, B, E}

R2 = {A, B, C, D}

R3 = {A, B, D, E}

R4 = {A, C, D, E}

R5 = {A, D, E}

R6 = {B, C, D}

R7 = {B, C, D, E}

R8 = {B, D, E}

R9 = {C, D, E}

Question 12

Not answered
v7 (latest)

Suppose we have the relational schema:


Student(uid, fname, lname) with primary key (uid)
Course(ccode, title, units) with primary key (ccode)
Exam(uid, ccode, result, semester) with primary key (uid, ccode)
and the SQL query
SELECT DISTINCT lname, result, title
FROM Student, Exam, Courses
WHERE Student.uid=Exam.uid
AND Exam.ccode=Course.ccode
AND result≤60;

Correctly complete each of the following statements:

• A = πlname,result,title((Student ⋈Student.uid=Exam.uid σresult≤60(Exam)) ⋈Exam.ccode=Course.ccode(Course)) is


.

• B = πlname,result,title(((Student ⋈Student.uid=Exam.uid σresult≤60(Exam)) ⋈Exam.ccode=Course.ccode πccode(Course))) is


.

• C = πlname,result,title((π{uid,lname(Student) ⋈Student.uid=Exam.uid σresult≤60(Exam)) ⋈Exam.ccode=Course.ccode πccode,title(Course)) is


.

• D = πlname,result,title((πuid,lname(Student) × σresult≤60(Exam)) ⋈Exam.ccode=Course.ccode(Course)) is


.

• E = πlname,result,title(σresult≤60((Student ⋈Student.uid=Exam.uid Exam) ⋈Exam.ccode=Course.ccode(πccode,title(Course)))) is


.

• The relational algebra expression that is equivalent to the SQL query and will be the most efficient to evaluate is .

(Max 6 marks.)
Question 13

Not answered
v2 (latest)

Consider the following two transactions:

T1 T2
read(B) read(A)
write(B) write(A)
read(A) read(B)
write(A) write(B)

In the list below, order the operations into an interleaved execution of both transactions such that a dirty read problem occurs in T1. (Max 6
marks.)

1 Choose...

2 Choose...

3 Choose...

4 Choose...

5 Choose...

6 Choose...

7 Choose...

8 Choose...

9 Choose...

10 Choose...
Question 14

Not answered
v12 (latest)

Alice owns two relations in the database:


City (name, state, population)
State (name, abbreviation, capital, area, population)
The following commands are executed in order:
(Alice): GRANT SELECT, UPDATE ON City TO Jane WITH GRANT OPTION;
(Alice): GRANT SELECT ON City TO Minnow;
(Alice): GRANT SELECT ON State TO Jane, Minnow WITH GRANT OPTION;
(Minnow): GRANT SELECT ON STATE TO Bob WITH GRANT OPTION;
(Jane): GRANT SELECT ON State TO Bob WITH GRANT OPTION;
(Jane): GRANT UPDATE ON City TO Bob;
(Bob): GRANT SELECT ON State TO Squid;
Part A: Which privileges will Jane and Squid have after the commands' execution? Fill in the table below.

SELECT on City UPDATE on City SELECT on State

Jane

Squid

Part B: Alice then executes the following commands:


(Alice): REVOKE SELECT ON STATE FROM Jane CASCADE;
(Alice): REVOKE UPDATE ON CITY FROM Jane RESTRICT;
Which privileges will Jane and Squid have after their execution? Fill in the table below.

SELECT on City UPDATE on City SELECT on State

Jane

Squid

(Max 6 marks.)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy