\begin{frame} \frametitle{Keys} \begin{block}{} A \textbf{key} of a relation $R$ is a set of attributes $\{\,A_1,\ldots,A_n\,\}$ that \textbf{uniquely identify} the tuples in $R$. \end{block} \pause \begin{goal}{} The \emph{key constraint} is satisfied in the DB state $I$ if and only if \begin{tcenter} $t.A_1 = u.A_1 \;\&\; \ldots \;\&\; t.A_n = u.A_n \quad\implies\quad t = u$ \end{tcenter} for all tuples $t,u \in I(R)$. \end{goal} So, different tuples differ in at least one of the values $A_1,\ldots,A_n$. \begin{exampleblock}{} If \sql{sid} is declared a key for \sql{Students}, this is \alert{illegal}: \centerline{% {\tableSmall \colorbox{rellight}{% \begin{tabular}[t]{|r|r|r|c|} \multicolumn{4}{c}{Students} \\ \hline \hd{\underline{sid}} & \hd{first} & \hd{last} & \hd{address} \\ \hline 101 & George & Orwell & \normalfont\ldots \\ 102 & Elvis & Presley & \normalfont\ldots \\ 101 & Lisa & Simpson & \normalfont\ldots \\ \hline \end{tabular}% }}% } \end{exampleblock} \pause \begin{alertblock}{} Once a key has been declared the DBMS will refuse any insertion of tuples with duplicate key values. \end{alertblock} \end{frame}