Search code examples
databaserelational-databasefunctional-dependencies

Non-trivial Functional Dependency of this table


Which non-trivial functional dependencies hold in the following table? Can anyone explain step by step the rules please?

A   B   C
------------
a1  b2  c1    
a2  b1  c6    
a3  b2  c4    
a1  b2  c5    
a2  b1  c3    
a1  b2  c7    

Solution

  • I'll start with a disclaimer to state that my knowledge of functional dependencies is limited to what was explained in the Wikipedia article, and that I currently don't have the need nor the inclination to study up on it further.

    However, since OP asked for clarification, I'll attempt to clarify how I obtained the seemingly correct answer that I posted in the comments.

    First off, this is Wikipedia's definition:

    Given a relation R, a set of attributes X in R is said to functionally determine another set of attributes Y, also in R, (written X → Y) if, and only if, each X value is associated with precisely one Y value; R is then said to satisfy the functional dependency X → Y.

    Additionally, Wikipedia states that:

    A functional dependency FD: X → Y is called trivial if Y is a subset of X.

    Taking these definitions, I arrive at the following two non-trivial functional dependencies for the given relation:

    • A → B
    • C → {A, B}

    Identifying these was a completely inductive process. Rather than applying a series of rules, formulas and calculations, I looked at the presented data and searched for those constraints that satisfy the above definitions.

    In this case:

    • A → B
      There are three possible values presented for A: a1, a2 and a3. Looking at the corresponding values for B, you'll find the following combinations: a1 → b2, a2 → b1, and a3 → b2. Or, every value of A is associated with precisely one B value, conforming to the definition.
    • C → {A, B}
      The same reasoning goes for this dependency. In this case, identifying it is a little bit easier as the values for C are unique in this relation. In this sense, C could be considered as a key. In database terms, a candidate key is exactly that: a minimal set of attributes that uniquely identifies every tuple.

    Undoubtedly, there's a way to mathematically derive the functional dependencies from the data, but for simple cases like this, the inductive process seems to work just fine.