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

Individual Assignment 2

This document contains questions for an individual database concepts assignment. It asks students to describe concepts related to the relational model like entity integrity, foreign keys, and normal forms. It also contains questions about relational algebra operations, SQL queries, database design for OLTP vs OLAP, and ensuring ACID properties in transactions.

Uploaded by

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

Individual Assignment 2

This document contains questions for an individual database concepts assignment. It asks students to describe concepts related to the relational model like entity integrity, foreign keys, and normal forms. It also contains questions about relational algebra operations, SQL queries, database design for OLTP vs OLAP, and ensuring ACID properties in transactions.

Uploaded by

Shawn Moyo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

HETT 205: DATABASE CONCEPTS

INDIVIDUAL ASSIGNMENT 2

Due: 16/07/20

Question 1

(a) Describe the relational model of data. [6 marks]

(b) Explain the following concepts in relational databases:

(i ) entity integrity constraint; [1 mark]

(ii ) foreign key and how it can specify a referential integrity constraint
between two relations; [4 marks]

(iii ) semantic integrity constraint. [1 mark]

(c) (i ) What is a functional dependency? [1 mark]

(ii ) Define Boyce-Codd Normal Form (BCNF). [3 marks]

(iii ) Define Third Normal Form (3NF). [3 marks]

(iv ) What is the relationship between BCNF and 3NF? [1 mark]

Question 2

(a) What is the difference between a key and a functional dependency? [3 marks]

(b) The schema R(A, B, C, D, E) has the following functional dependencies.

A, B → C
B, C → D
C, D → E
D, E → A

(i ) What are all of the keys of R? [3 marks]

(ii ) Which functional dependencies violate Boyce–Codd Normal form


(BCNF)? [3 marks]

(iii ) Which functional dependencies violate Third Normal form (3NF)?


[3 marks]

(iv ) Find a lossless-join decomposition of R into BCNF relations. [8 marks]

1
Question 3

(a) Suppose that R(A, B, C) is a relational schema with functional dependencies


F = {A, B → C, C → B}.

(i ) Is this schema in 3NF? Explain. [2 marks]

(ii ) Is this schema in BCNF? Explain. [2 marks]

(b) Decomposition plays an important role in database design.

(i ) Define what is meant by a lossless-join decomposition. [2 marks]

(ii ) Define what is meant by a dependency preserving decomposition.


[2 marks]

(c) Let R(A, B, C, D, E) be a relational schema with the following functional


dependencies
A, B → C
D, E → C
B → D
(i ) What is the closure of {A, B}? [2 marks]

(ii ) What is the closure of {B, E}? [2 marks]

(iii ) Decompose the schema to BCNF in two different ways. In each case, are
all dependencies preserved? Explain. [4 + 4 marks]
Question 4

(a) Define the operators in the (core) relational algebra. [6 marks]

(b) The core relational algebra is often extended with other operators. For the
following operators give a definition and an example of their behaviour:

(i ) the full outer join operator; [3 marks]

(ii ) the aggregate and grouping operator. [5 marks]

(c) X, Y and Z are all relations with a single attribute A. A naı̈ve user wishes
to compute the set-theoretic expression X ∩ (Y ∪ Z) and writes the following
SQL query.

SELECT X.A
FROM X,Y,Z
WHERE X.A=Y.A OR X.A=Z.A

(i ) Give the relational algebra term that this query would be compiled to.
[2 marks]

(ii ) Does the SQL query satisfy the user’s expectation? Justify your answer.
[4 marks]
2
Question 5

Assume a simple movie database with the following schema. (You may assume
that producers have a unique certification number, Cert, that is also recorded in
the Movie relation as attribute prodC#; and no two movies are produced with the
same title.)

Movie(title,year,length,prodC#)
StarsIn(movieTitle,movieYear,starName)
Producer(name,address,cert)
MovieStar(name,gender,birthdate)

(a) Write the following queries in SQL:

(i ) Who were the male stars in the film The Red Squirrel ? [1 mark]

(ii ) Which movies are longer than Titanic? [2 marks]

(b) SQL has a boolean-valued operator IN such that the expression s IN R is true
when s is contained in the relation R (assume for simplicity that R is a single
attribute relation and hence s is a simple atomic value).

Consider the following nested SQL query that uses the IN operator:

SELECT name
FROM Producer
WHERE cert IN (SELECT prodC#
FROM Movie
WHERE title IN (SELECT movieTitle
FROM StarsIn
WHERE starName='Nancho Novo'));

(i ) State concisely what this query is intended to mean. [1 mark]

(ii ) Express this nested query as a single SELECT-FROM-WHERE query.


[2 marks]

(iii ) Is your query from part (b)(ii ) always equivalent to the original query? If
yes, then justify your answer; if not, then explain the difference and show
how they could be made equivalent. [6 marks]

(c) SQL has a boolean-valued operator EXISTS such that EXISTS R is true if and
only if R is not empty.

Show how EXISTS is, in fact, redundant by giving a simple SQL expression
that is equivalent to EXISTS R but does not involve EXISTS or any cardinality
operators, e.g. COUNT. [Hint: You may use the IN operator.] [8 marks]

3
Question 6

(a) OLAP and OLTP.

(i ) What is on-line transaction processing (OLTP)? [2 marks]

(ii ) What is on-line analytic processing (OLAP)? [2 marks]

(iii ) If you were designing a relational database system, how would your
approach to schema design differ for OLTP and OLAP systems?
[3 marks]

(iv ) In OLAP, what is the meaning of the terms drill down, roll up, and slice?
[3 marks]

(v ) What is a star schema? [1 mark]

(b) Suppose we have the following relational schema,

Supplier(sid:integer, name:string, postcode:string)


Parts(pid:integer, name:string, description:string)
SuppliedBy(sid:integer, pid:integer, weight:integer)

where the underlined attributes represent the primary keys of the associated
relation. The table SuppliedBy implements a relationship between suppliers
and parts — indicating which parts are supplied by which supplier — using
foreign keys pointing into the Parts and Supplier tables. The weight attribute
is the parts weight in grams.

Write an SQL query that will return a list, without duplicates, of all postcodes
associated with suppliers of parts less than one kilogram in weight. [5 marks]

(c) Define and explain the ACID properties of database transactions. [4 marks]

You might also like