Test 1 Review B: Questions

R1b.1.

Define the term functional dependency (represented using the notation A → B), and identify and explain at least two unrelated functional dependencies based on the below table schema; each should be nontrivial.

customers(cust_id, name, city, state, zip)
R1b.2.

Suppose we had a relation giving students and their advisors, including advisor, student, major (assuming each student has exactly one major). A classmate suggests that the FD advisor major → student would apply to this relation. Give a realistic example of specific rows in this relation that would be inconsistent with this. (Use last names to identify advisors and students.)

R1b.3.

Consider the following table for Super Bowl results, with some example rows listed for the years 2008–2012.

yearcitymascotscoreopponent
2012New YorkGiants2117
2011Green BayPackers3125
2010New OrleansSaints3117
2009PittsburghSteelers2723
2008New YorkGiants1714

Would mascot → city be an FD for this table? Explain why or why not. (There's no penalty for inaccurate impressions of how football works, given that your assumptions are well-stated and reasonable.)

R1b.4.

Hendrix's Public Safety office proposes the following schema for tracking parking permits.

permits(permit_number, student_id, vin, tag_state, tag_number, year, make, model)

The tag_state and tag_number attributes are for identifying cars by license plate, and the vin attribute tracks the vehicle identification number, which is unique to each car in the world.

For each of the following proposed functional dependencies, explain why or why not it would apply to this table.

  1. tag_state tag_numberstudent_id
  2. year make modelpermit_number
R1b.5.

Identify and explain at least two unrelated functional dependencies based on the below table schema; each should be nontrivial.

orders(invoice_id, customer_name, item_id, cost)
R1b.6.

Suppose we have a relation for college courses with the following schema.

courses(discipline, number, title, description, department)

For example, it might contain the following.

disciplinenumbertitledescriptiondepartment
CSCI340Database Systemsa fun courseMathematics & Computer Science
MATH130Calculus Ia good courseMathematics & Computer Science
SPAN110Spanish Ian introductory courseForeign Languages

Write down at least two substantially different nontrivial functional dependencies that this table would have (based on the above table and what you know about Hendrix).

R1b.7.

For the following schema, identify a nontrivial functional dependency (FD) and explain why the functional dependency might apply to the table, with specific reference to the attributes' meaning.

locations(latitude, longitude, elevation, place_name)
R1b.8.

Hendrix's Public Safety office proposes the following schema for tracking parking permits.

permits(permit_number, student_id, vin, tag_state, tag_number, year, make, model)

The tag_state and tag_number attributes are for identifying cars by license plate, and the vin attribute tracks the vehicle identification number, which is unique to each car in the world. Public Safety is willing to issue multiple permits to the same person, to different vehicles; but no vehicle ever receives multiple permits.

Identify three different keys for this table. Feel free to specify any unusual assumptions you must make for a key to be valid.

R1b.9.

Suppose we have a relation R(a, b, c, d, e) with the following functional dependencies.

a bc
c de
d eb

  1. What is the closure of { abe }?

  2. What are the keys for R?

R1b.10.

Suppose we have a relation R(abcde) with the following functional dependencies.

a b → d
a c → e
a e → c
  1. What is the closure of {ac}?

  2. What are the keys for R?

R1b.11.

Suppose we have a relation R(a, b, c, d) with the functional dependencies a b → c, a c → b, and b d → a. Identify the keys for this relation.

R1b.12.

Suppose we have the schema R(a, b, c, d), with the FDs c → b, a c → d, and b d → c. Identify two keys for R.

R1b.13.

Complete the following definition: A relation is in BCNF (Boyce-Codd Normal Form) if for every FD applying to the table, the FD is either trivial or…?

R1b.14.

What condition must a relation satisfy to be in Boyce-Codd Normal Form (BCNF)?

R1b.15.

Give an example of a relation for Hendrix housing assignments that is not in BCNF. Explain why your relation is not in BCNF by giving a specific violating FD and explaining why it violates BCNF.

R1b.16.

Give an example of a relation describing a library card catalog that is not in BCNF. Explain specifically why your relation is not in BCNF.

R1b.17.

Give an example of a relation describing a telephone directory that is not in BCNF. Explain specifically why your relation is not in BCNF.

R1b.18.

Suppose we have a relation whose attributes are a, b, c, d, and e with the FD basis:

a bc, b ed, a db c

a. What are the keys for this relation? (There are two.)

b. Explain why this relation is not in Boyce-Codd Normal Form, with specific reference to the relation and its FDs.

R1b.19.

Suppose we have the schema R(a, b, c, d) with the FD a → b d. The set {a, c} is a key for R. Explain why this relation is not in BCNF, and decompose it into two relations that are in BCNF.

R1b.20.

Suppose that we have a relation R(a, b, c, d) with the functional dependencies

ab
a cd
b dc
b c da

The keys for this relation are { ac }, { ad }, and { bd }. Decompose the relation so that it is in BCNF, and explain your answer.

R1b.21.

Suppose we have a relation R(abcde) with the following functional dependencies.

a b → c
b c → d
c d → e

The one key for this relation is {ab}. Explain why this relation is not in BCNF, with specific reference to its FDs. Decompose the relation into BCNF relations, explaining with each step which FD you are using.

Test 1 Review B: Solutions

R1b.1.

A functional dependency A → B applies to a relation if for any two rows agreeing on the attributes of A, those rows must necessarily agree on the attributes of B.

Examples for the given table include:

cust_idname city state zip
zipcity state
R1b.2.
advisormajorstudent
BurchCSCIBrown
BurchCSCIGreen
R1b.3.

No, it is not a valid FD, because teams sometimes switch cities keeping the same mascot; thus, knowing the mascot, I cannot determine the city. An example would be the Oakland Raiders, who moved to Los Angeles in the 1982 while remaining the Raiders, and then they moved back to Oakland in 1995. In fact, they actually did win the Super Bowl both as the Oakland Raiders and as the Los Angeles Raiders; although even if they did not, such a circumstance could happen in the future. (Another example is the Colts, who moved from Baltimore to Indianapolis in 1984, preserving their mascot. They won both before (1970) and after (2006) that move.)

(However, both the year and the mascot would be enough to determine the city, so that would be a valid FD: The NFL ensures that no two teams have the same mascot.)

R1b.4.
  1. This is an FD, since the state and tag number specify a unique license plate, which will be unique to each student.
  2. This is not an FD, since two different students would have cars of identical year, make, and model (for example, two students might have 2008 Volkswagen Beetles), so the table could include two rows with different permit numbers and an identical year-make-model combination.
R1b.5.

One FD is invoice_id → customer_name, since only one customer receives each invoice.

Another potential example is the FD item_id → cost, asserting that each item has a fixed cost charged to all customers. This FD may not apply: Items' costs may change over time, and it may be that special discounts are negotiated for some particular customers. In that case, a reasonable alternative is invoice_id item_id → cost, asserting that on any invoice, only one cost for an item appears.

R1b.6.

disciplinedepartment
discipline titlenumber description

(I'd accept discipline numbertitle, too, but actually the titles vary on some topics courses (as CSCI 490).)

R1b.7.

latitude longitude → elevation would likely apply: The latitude and longitude identify a particular location on the earth's surface, which would have an unique elevation associated with it.

R1b.8.

{permit_number}, {vin}, and {tag_state, tag_number}

R1b.9.
  1. { a, b, c, e }

  2. abd }, { acd }, { ade }

R1b.10.
  1. {ace}

  2. The keys are {abc} and {abe}.

R1b.11.

bd }, { acd }

R1b.12.
{a, c},  {a, b, d}
R1b.13.

…its left side is a superkey.

R1b.14.

Every nontrivial function dependency must have a left side that is a superkey (i.e., the left side of the functional dependency must actually determine all attributes of the relation).

R1b.15.

rooms(student_idlast_namehallroom_nofloor_area)

This is not in BCNF because hall room_no → floor_area is a valid FD: After all, hall and room_no together specify the exact room, so we know the floor area just from that information. However, its LHS {hallroom_no} is not a superkey, since some rooms have multiple students assigned to them and so student_id cannot be determined from just these two attributes.

R1b.16.

books(call_number, title, author, birth_date)

It would be reasonable to suppose that the FD author → birth_date would apply to this relation, as each author can only be born in on one day (ignoring the issue of multiple authors with identical names). However, author is not itself a superkey, since the library may contain multiple books by some authors, so this relation is not in BCNF.

R1b.17.

directory(name, address, phone)

If multiple people may be listed for the same telephone number, then phone is not itself a superkey, since it is not enough to identify a single row of the relation. But the FD phone → address might also apply to this relation, in which case the relation is not in BCNF, since the FD's left side (phone) is not itself a superkey.

R1b.18.

a. The keys are {a, b, e} and {a, d, e}. (Any key must include a and e, since neither of these can be determined from any FD; but these don't on their own determine anything. Moreover, adding c doesn't help determine either of the remaining attributes — adding b to a and e determines all other attributes, as does adding d.)

b. It is not in BCNF because the FD a b → c has a left side ({a, b}) that is not a superset of one of the keys. (For that matter, none of the three listed FDs have a left side that's a superset of one of the keys.)

R1b.19.

It is not in BCNF since the FD's left side isn't a superkey — in fact, it is a proper subset of the key.

The relation would be decomposed into the two BCNF relations S(a, b, d) and T(a, c).

R1b.20.

It is not in BCNF due to the a → b FD. We can decompose the relation into two BCNF relations, S(a, b) and T(a, c, d).

R1b.21.

It is not in BCNF because the FD b c → d does not have a superkey on its left side: {bc} is not a superset of {ab}. (The FD c d → e has the same problem.)

To decompose, we might first start with the violating FD b c → d. Note that the closure of {bc} is {bcde}, so we decompose R into (bcde) and (abc). We'd then observe that the first relation isn't in BCNF due to the c d → e FD, so we'd split this relation further into (cde) and (bcd). We thus end up with three relations: (abc), (cde), and (bcd).