title: Decomposition to BCNF
body: <p>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.</p>
  
  <p>A specific exercise I ran into today was this:
  Given this DB, convert it to BCNF:</p>
  
  <pre><code>DB:  
  AB -&gt; EF  
  F -&gt; AB  
  A -&gt; CD
  </code></pre>
  
  <p>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.</p>
  
  <p>Let's say we go with F as the primary key.<br>
  Originally: <code>DB(F-&gt;AB)</code></p>
  
  <p>For 1NF there seems to be no repeating groups. Check.<br>
  For 2NF there seems to be no partial dependencies. (Would this not be impossible with F being the only primary key?)<br>
  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)</p>
  
  <pre><code>DB(F-&gt;AB)
  R1(AB-&gt;EF)
  R2(A-&gt;CD)
  </code></pre>
  
  <p>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;</p>
  
  <p>First occurrence is F->AB. This is the primary key and is thus OK.<br>
  Second occurence is AB->EF. Since AB is a candidate key, this is OK as well.<br>
  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?</p>