How to search in rails from two models?

Functional dependencies minimization: can two func. dependencies delete each other?

  • For what i know actually, given a relation R(u), where u are (a list of) attributes of the relation R, and a set of functional dependencies F, it's better to obtain the minimal set of functional dependencies to reduce cost of checking if a tuple is valid for F. Then we search F_{min} = \min{|F'|} where \forall \ F' : |F'| \le |F| \wedge F' \models F (1). Now, to minimize F, i know the following concept: Given X \rightarrow Y \in F if F \setminus \{ X \rightarrow Y  \} \models F then X \rightarrow Y can be deleted. (this can be applied to "minimize right parts") But i'm in trouble if two functional dependencies delete each other. Is it right? I give an example: On R(A, B, C, D, E, F) (i use capital letters but they are single attributes), we have F= \{ D \rightarrow C , E \rightarrow C , AC \rightarrow D , AC \rightarrow E,  A \rightarrow F , D \rightarrow F , F \rightarrow A , EA \rightarrow B , DE \rightarrow B \} . The algorithm that I use to check if a FD is redundant is the following: Given Z = F \setminus \{ X \rightarrow Y  \} and let X^+= X. While X^+ change, do: \forall J \rightarrow K \in Z if J \subseteq X^+ then X^+ := X^+ \cup K In the end, if Y \in X^+ then X \rightarrow Y can be deleted. But in the example given above, we have (2): \{ EA \rightarrow B \} . (EA)^+= EAFCDEB so it is cancellable. \{ DE \rightarrow B \} . (DE)^+= DEFAB also this is cancellable. Then i delete both, but so F' = F \setminus \{ EA \rightarrow B , DE \rightarrow B \} cannot implies B, so seems that F' \not \models F . Now i see two options: what i know is incomplete, then i'm doing wrong things, or what can't be implied (the attribute B) is in the keys of R and F' is fine. What is the right answer? (1) |F| means the number of functional dependencies (FD) in canonical form. Canonical form for a FD: X \rightarrow Y where X is a list of attributes or X \subseteq  u while Y is a single attribute. (2) I use \{ X \rightarrow Y \} . X^+= to point "the closure of attributes X on the set  Z = F \setminus \{ X \rightarrow Y  \} "

  • Answer:

    The procedure to reach F_{min} should indeed proceed by eliminating single redundant FDs and after that look for the next one to eliminate. So do not eliminate at each step all FDs that at that point are redundant, as you seem to suggest. Eliminating them one by one makes the algorithm non-deterministic, and that is how it should be, because in some cases there is not a unique F_{min}.

Jan Hidders at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.