\frametitle{How to Determine Keys}

%   In the following algorithm we assume that for all FDs $\alpha_i \to \beta_i$
%   we have $\alpha_i \cap \beta_i = \varnothing$
%   (the lhs and rhs share no attributes).
%   \medskip
  \begin{code}{\textwidth}{\small Finding a Minimal Key}
      \emph{Input:}  & \mathcal{A} \text{ (set of all attributes of $R$)} \\
      & \alpha_1 \to \beta_1, \dots, \alpha_n \to
      \beta_n \text{ (set of FDs $\mathcal{F}$)} \\
      \emph{Output:} & \alpha \text{ (a minimal key of $R$)} \\
      \STATE $x = \mathcal{A}$;
      \FORALL{attributes $A \in X$} 
      \IF{$A \in \{x-A\}^+_{\mathcal{F}}$}
      \STATE $x = x - A$; \text{\quad (remove $A$ from $x$)}
      \STATE \textbf{return} $x$;
  We might get different keys depending on the order in \textbf{for all}.
%   \pause
%   \begin{alertblock}{}
%     This algorithm is not good if we want to find all minimal keys.\\
%     \remark{There are too many permutations of the FDs $\alpha_i \to \beta_i$ to check.}
%   \end{alertblock}