\begin{frame} \frametitle{Finding all Minimal 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{-1ex} \begin{algorithmic} \STATE $\textit{Results} = \varnothing$; \STATE $\textit{Candidates} = \{\; \{\, A_i \mid \text{$A_i$ is not part of any right-hand side in $\mathcal{F}$} \,\} \;\}$; \WHILE{$\textit{Candidates} \ne \varnothing$} \STATE choose and remove a smallest $\kappa \in \textit{Candidates}$; \IF{$\kappa$ contains no key in \textit{Results}} \IF{$\kappa^+_{\mathcal{F}} = \{\, A_1,A_2,\ldots,A_n \,\}$} \STATE $\textit{Results} = \textit{Results} \cup \{\kappa\}$; \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 \ENDIF \ENDWHILE \STATE \textbf{return} $\textit{Results}$; \end{algorithmic} \end{code} \end{frame}