69/77
\begin{frame}
  \frametitle{Foreign Keys}

  \begin{goal}{}
    A foreign key implements a \textbf{one-to-many relationship}.
  \end{goal}

  \begin{exampleblock}{}
    In table \sql{Results}, \sql{sid} is a foreign key referencing \sql{Students}
    {\fontsize{7.5}{9}\ttfamily
    \parbox[b]{.5\textwidth}{
    \medskip
    \colorbox{rellight}{%
      \begin{tabular}[t]{|r|r|r|c|}
        \multicolumn{4}{c}{Students} \\ \hline
        \hd{\underline{sid}} & \hd{first} & \hd{last} & \hd{\normalfont$\cdots$} \\ \hline
        101 & George & Orwell & \normalfont$\cdots$\anchor{row-101}\\ 
        102 & Elvis & Presley & \normalfont$\cdots$\anchor{row-102}\\ 
        103 & Lisa & Simpson & \normalfont$\cdots$\anchor{row-103}\\ 
        104 & Bart & Simpson & \normalfont$\cdots$\anchor{row-104}\\ 
        105 & George & Washington & \normalfont$\cdots$\anchor{row-105}\\
        \hline
      \end{tabular}%
    }}\hfill
    \colorbox{rellight}{%
      \begin{tabular}[t]{|r|r|r|r|}
        \multicolumn{4}{c}{Results} \\ \hline
        \hd{\underline{sid}} & \hd{\underline{category}} & \hd{\underline{number}} & \hd{points} \\ \hline
        \anchor{from-101a}101 & exam & 1 & 12 \\ 
        \anchor{from-101b}101 & homework & 1 & 10 \\ 
        \anchor{from-102a}102 & exam & 1 & 10 \\ 
        \anchor{from-102b}102 & homework & 1 & 9 \\ 
        \anchor{from-105}105 & exam & 1 & 7 \\ 
        \anchor{from-107}107 & homework & 1 & 5 \\
        \hline
      \end{tabular}%
    }}
    \begin{tikzpicture}[remember picture,overlay]
      \begin{scope}[very thick,dblue]
      \draw [->] ($(from-101a)+(-3mm,0mm)$) to[out=180,in=0] ($(row-101)+(2.5mm,0mm)$);
      \draw ($(from-101b)+(-3mm,0mm)$) to[out=180,in=0] ($(row-101)+(2.5mm,0mm)$);
      \draw [->] ($(from-102a)+(-3mm,0mm)$) to[out=180,in=0] ($(row-102)+(2.5mm,0mm)$);
      \draw ($(from-102b)+(-3mm,0mm)$) to[out=180,in=0] ($(row-102)+(2.5mm,0mm)$);
      \draw [->] ($(from-105)+(-3mm,0mm)$) to[out=180,in=0] ($(row-105)+(2.5mm,0mm)$);
      \only<3->{
         \draw [->,red] ($(from-107)+(-3mm,0mm)$) to[out=180,in=0] node [at end,xshift=-2mm] {?} ($(from-107)+(-15mm,-3mm)$);
      }
      \end{scope}
    \end{tikzpicture}\vspace{1.5ex}
  \end{exampleblock}
  \pause
  
  \begin{goal}{}
    \textdbend \quad \parbox[b]{.7\textwidth}{
      \textbf{Foreign keys are not themselves keys.}\\
      Here \sql{sid} is not a key of \sql{Results}.
    }
  \end{goal}  
  \pause\pause
  
  \begin{alertblock}{}
    We need an \textbf{existence guarantee} for key values in \sql{Students}.
  \end{alertblock}
  The set of \sql{sid} values appearing in \sql{Students}
  forms a \textbf{dynamic domain} for the attribute \sql{Results.sid}.
  \vspace{10cm}
\end{frame}