\begin{frame}[fragile] \frametitle{Relations as Query Results} \begin{goal}{} \emph{Query:} PID and Name of everybody who has chatted. \end{goal} \pause \begin{exampleblock}{Relational Model} \vspace{-1ex} \begin{talign} &\{\; \pair{x}{y} \;\mid\; \mpause[1]{ \myex{z}{\text{\textit{Person}}(x,y,z)} } \\ &\hspace{1.3cm} \mpause{ \;\wedge\; \myex{c_1,c_2,c_3}{(\, \text{Chat}(c_1,x,c_2,c_3) \vee \text{Chat}(c_1,c_2,x,c_3)\,) }} \; \} \end{talign} \end{exampleblock} \pause\pause\pause \begin{exampleblock}{Tuple Model} \vspace{-1ex} \begin{talign} &\{\; \pair{\,\text{PID}(p)}{\,\text{Name}(p)\,} \;\mid\; \text{\textit{Person}}(p) \\ &\hspace{.9cm} \mpause[1]{ \;\wedge\; \myex{c}{(\, \text{Chat}(c) \wedge (\;\text{P1}(c) = \text{PID}(p) \vee \text{P2}(c) = \text{PID}(p)\;)\,) }} \; \} \end{talign} \end{exampleblock} \pause\pause \begin{exampleblock}{SQL Query} {\small \begin{verbatim}SELECT P.PID, P.Name FROM Person as P WHERE EXISTS ( SELECT * FROM Chats as C WHERE C.P1 = P.PID OR C.P2 = P.PID )\end{verbatim}% } \end{exampleblock} \end{frame}