94/296
\begin{frame}
\frametitle{How to Determine Keys}

\begin{code}{\textwidth}{\small Finding \emph{all} Minimal Keys}
\small
$\begin{array}{ll} \emph{Input:} & A_1,A_2,\ldots,A_n \text{ (all attributes of$R$)} \text{ and } \mathcal{F} \text{ (set of FDs)} % \emph{Output:} & \textit{Results} \text{ (the set of all minimal keys of$R$)} \\ \end{array}$\vspace{-2ex}
\begin{algorithmic}
\STATE $\textit{Results} = \varnothing$;
\STATE $\textit{Candidates} = \{\{A_1\},\{A_2\},\ldots,\{A_n\}\}$;
\WHILE{$\textit{Candidates} \ne \varnothing$}
\STATE choose and remove a smallest $\kappa \in \textit{Candidates}$;
\IF{$\kappa^+_{\mathcal{F}} = \{A_1,A_2,\ldots,A_n\}$}
\IF{$\kappa$ contains no key in \textit{Results}}
\STATE $\textit{Results} = \textit{Results} \cup \{\kappa\}$;
\ENDIF
\ELSE
\FORALL{$A_i \not\in \kappa^+_{\mathcal{F}}$}
\STATE $\kappa_i = \kappa \cup \{A_i\}$;
\STATE $\textit{Candidates} = \textit{Candidates} \cup \{\kappa_i\}$;
\ENDFOR
\ENDIF
\ENDWHILE
\STATE \textbf{return} $\textit{Results}$;
\end{algorithmic}
\end{code}
\end{frame}