Post-Class Assignment FDs and Normalization
Post-Class Assignment FDs and Normalization
You will need to submit this assignment through Gradescope. The assignment will be
autograded, and you can submit as many times as you wish before the deadline. The last
submission is the one that will count, so make sure it contains all your responses.
IMPORTANT: While you can submit an unlimited number of times, the auto-
grader will only show you feedback on questions Q1, Q2, Q3, and Q4 for your
first two submissions each day. The reason for this is to limit trial and error
submissions to guess a closure or a decomposition. Starting work on the assign-
ment early will give you more opportunities for feedback, as the submission counter
resets each day. (The feedback to Q5 and Q6 will always be hidden until after the
deadline, and the feedback for Q7 will be visible for all submissions.)
1. Q1: Consider the following relational schema and set of functional dependencies.
R(A,B,C,D,E) A → CD
DE → BC
Rewrite this CREATE TABLE statement to indicate the appropriate primary key. Submit
your statement in file Q1.sql.
1
CMPSCI 345 Post-class assignment FDs and normalization
2. Q2: Consider the following relational schema and set of functional dependencies.
S(A,B,C,D,E,F,G) D→E
E→B
C → FG
BE → AC
Rewrite this CREATE TABLE statement to indicate the appropriate primary key. Submit
your statement in file Q2.sql.
3. Q3: Consider the following relational schema and set of functional dependencies.
T(A,B,C,D,E) AB → D
C→E
E→B
Rewrite this CREATE TABLE statement to indicate the appropriate primary key. Submit
your statement in file Q3.sql.
4. Q4: Consider relation S from Q2. That relation is not in BCNF. Decompose it into two
or more relations, using the BCNF decomposition algorithm, so that your final schema
is in BCNF. Name your relations S1, S2, S3, etc. You will need to write queries to
move the data from S into your new relations. For example, if you decide that your final
BCNF schema is S1(A,B,C, D), S2(D, E, F), S3(E, G), you should write the queries:
CREATE TABLE S1 AS
(SELECT A, B, C, D FROM S);
CREATE TABLE S2 AS
(SELECT D, E, F FROM S);
CREATE TABLE S3 AS
(SELECT E, G FROM S);
Don’t worry about specifying keys in your new relations; just move the data as described
above. Submit your statements in file Q4.sql.
Page 2
CMPSCI 345 Post-class assignment FDs and normalization
5. Q5: Consider S from Q2. Is the decomposition of S into S1(E,G,F) and S2(A,B,C,D,G)
a lossless join decomposition?
Choose one of the following queries as your answer:
SELECT ’lossy’;
SELECT ’lossless’;
6. Q6: Consider relation W(A,B,C,D), different than the relations in prior questions. We
are told that W is in BCNF, and that exactly 3 out of the 4 FDs listed below hold for
W. Choose the FD that W does not satisfy.
1: C → ABD
2: AD → C
3: B → D
4: BD → A
SELECT answer;
The relation is currently empty. You have to insert exactly 3 tuples into the relation,
without duplicates, to create a data instance in which the functional dependency A →
BC holds and the functional dependencies B → C and C → B do not hold.
Submit your 3 insert statements in file Q7.sql.
Page 3