Pregunta

While I do understand what the normal forms are, I have trouble working with them. I am following a course in database systems and somehow I am a bit lost on this. I have tried Google, stackoverflow, slides of the course and the book, but examples seem to throw me off track every time. I would very much like some pointers if I make some wrong assumptions/conclusions along this post, but also some pointers as to what I am missing in the end.

A specific exercise I ran into today was this: Given this DB, convert it to BCNF:

DB:  
AB -> EF  
F -> AB  
A -> CD

As I understand it there are two possible candidate keys here. AB and F. This is because both are able to derive the entire DB, and because both are minimal in the sense that they consist of a single left hand side.

Let's say we go with F as the primary key.
Originally: DB(F->AB)

For 1NF there seems to be no repeating groups. Check.
For 2NF there seems to be no partial dependencies. (Would this not be impossible with F being the only primary key?)
For 3NF there's a problem! Both AB and A are not keys but determines other attributes. To solve this, they need to become keys: (Sorry for the lack of underlining, seems there is no option to underline)

DB(F->AB)
R1(AB->EF)
R2(A->CD)

As I understand it, for BCNF, the procedure goes like this: Compare the 3NF DB with the original DB. Find occurences in the original DB where the entire left hand side is present the 3NF DB and at least one right hand side is present. I am not quite sure how it is ever possible to not have this. Maybe i misunderstood this part. Anyways, continuing;

First occurrence is F->AB. This is the primary key and is thus OK.
Second occurence is AB->EF. Since AB is a candidate key, this is OK as well.
Last occurence is A->CD. A is only part of a candidate key. This violates BCNF and must be rewritten. And this is where I get off the train completely. I have no idea how to rewrite this, and I am not sure if the procedure so far makes sense. Could anyone help me wrap it up?

¿Fue útil?

Solución

You're right: A->CD is the dependency which violates BCNF. You split your relation in two:

  • attributes from the violating dependecy: ACD
  • attributes from the right side of the violating dependency (A) together with the remaining attributes: thus you get ABEF

This is where you stop as all functional dependencies conform to BCND rules.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top