\begin{frame}[fragile]
\frametitle{Data Types and Domains}
\begin{block}{}
The \emph{domain} $\dom{D}$ of a type $D$ is the set of possible values.
\end{block}
\begin{exampleblock}{}
\begin{malign}
\dom{\sql{int}} &= \{ \sql{-2147483648}, \dots, \sql{2147483647} \} \\
\dom{\sql{numeric(2,0)}} &= \{ \sql{-99}, \dots, \sql{99} \}
\end{malign}
\end{exampleblock}
\pause\smallskip
SQL allows to define \textbf{application-specific domains}
as subsets of standard data types:
\begin{center}
\begin{code}{.8\textwidth}{}
\small
\sql{create domain ExampleDomain as numeric(2,0)}
\end{code}
\end{center}
We may even add constraints:
\begin{center}
\begin{code}{.94\textwidth}{}
\small
%###
\begin{verbatim}
create domain ExampleDomain as numeric(2,0) check(value > 0)
\end{verbatim}
%###
\end{code}
\end{center}
\pause
Domains are useful to document that two columns represent the same kind of objects and that comparisons are meaningful.
\bigskip
\end{frame}