\documentclass[11pt]{scrartcl}

\usepackage[top=1.5cm]{geometry}
\usepackage{url}
\usepackage{float}
\usepackage{listings}
\usepackage{xcolor}

\setlength{\parindent}{0em}
\setlength{\parskip}{0.5em}

\newcommand{\youranswerhere}{[Your answer goes here \ldots]}
\renewcommand{\thesubsection}{\arabic{subsection}}

\lstdefinestyle{dbtsql}{
  language=SQL,
  basicstyle=\small\ttfamily,
  keywordstyle=\color{magenta!75!black},
  stringstyle=\color{green!50!black},
  showspaces=false,
  showstringspaces=false,
  commentstyle=\color{gray}}

\title{
  \textbf{\large Assignment 7} \\
  Transaction Chopping \\
  {\large Database Tuning}}

\author{
  Group Name (e.g. A1, B5, B3) \\
  \large Lastname1 Firstname1, StudentID1 \\
  \large Lastname2 Firstname2, StudentID2 \\
  \large Lastname3 Firstname3, StudentID3
}

\begin{document}

\maketitle

\paragraph{Notes}

\begin{itemize}
  \item The chopping graphs may also be drawn by hand and attached as a hard copy on paper. In the case of drawings on paper, you need to hand in the drawings during the lab.
  \item The chopping graphs need to show all S- and C-edges, and you need to cross out (or otherwise mark) the S-edges that must be removed to get a correct chopping. Also show the write list for each chopping graph.
\end{itemize}

\subsection{Bank Accounts}

\paragraph{SQL Queries}

Give the SQL queries (including pseudo code if necessary) for each transaction.

\begin{enumerate}
  \item[T1:]\mbox{}

\begin{lstlisting}[style=dbtsql]
[Your SQL query goes here ...]
\end{lstlisting}

  \item[T2:]\mbox{}

\begin{lstlisting}[style=dbtsql]
[Your SQL query goes here ...]
\end{lstlisting}

  \item[T3:]\mbox{}

\begin{lstlisting}[style=dbtsql]
[Your SQL query goes here ...]
\end{lstlisting}
\end{enumerate}

\paragraph{Model Transactions}

Model all transactions with read/write operations.

\emph{Note:} Define the data items first, for example, $a_1$ is account\,1, $b_1$ is branch\,1, etc. Define the minimum number of data items that represent all possible conflicts in the scenario.

\begin{enumerate}
  \item[T1:] \youranswerhere{}
  \item[T2:] \youranswerhere{}
  \item[T3:] \youranswerhere{}
\end{enumerate}

\paragraph{Chopping Graph}

Show the chopping graph and give the finest possible correct chopping.

{\small
\parskip0pt\begin{verbatim}
[Your chopping graph goes here ...]
\end{verbatim}}

Finest correct chopping:
\begin{enumerate}
  \item[T1:] \youranswerhere{}
  \item[T2:] \youranswerhere{}
  \item[T3:] \youranswerhere{}
\end{enumerate}

\paragraph{Two Transactions Update the Same Account}

How does the chopping change if two concurrent transactions of type $T_1$ can update the same account? Explain.

\youranswerhere{}

\paragraph{Order of Atomic Operations}

The order of atomic operations in $T_3$ has an impact on the chopping. Show
two semantically equivalent implementations of $T_3$, one which favors chopping,
the other which does not favor chopping. Explain both.

\youranswerhere{}

\subsection{Chopping Graphs}

\paragraph{All Transactions}\mbox{}

{\small
\parskip0pt\begin{verbatim}
[Your chopping graph goes here ...]
\end{verbatim}}

Finest correct chopping:
\begin{enumerate}
  \item[T1:] \youranswerhere{}
  \item[T2:] \youranswerhere{}
  \item[T3:] \youranswerhere{}
  \item[T4:] \youranswerhere{}
  \item[T5:] \youranswerhere{}
  \item[T6:] \youranswerhere{}
\end{enumerate}

\paragraph{All Transactions Except T4}\mbox{}

{\small
\parskip0pt\begin{verbatim}
[Your chopping graph goes here ...]
\end{verbatim}}

Finest correct chopping:
\begin{enumerate}
  \item[T1:] \youranswerhere{}
  \item[T2:] \youranswerhere{}
  \item[T3:] \youranswerhere{}
  \item[T5:] \youranswerhere{}
  \item[T6:] \youranswerhere{}
\end{enumerate}

\subsection*{Time Spent on this Assignment}

Time in hours per person: \textbf{XXX}

\subsection*{References}

\begin{table}[H]
  \centering
  \begin{tabular}{c}
    \hline
    \textbf{Important:} Reference your information sources! \tabularnewline
    Remove this section if you use footnotes to reference your information sources. \tabularnewline
    \hline
  \end{tabular}
\end{table}

\end{document}
