% Created 2022-09-28 Wed 22:36
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{amsfonts} \usepackage{amssymb} \usepackage{mathtools} \usepackage{ upgreek } \usepackage{ textcomp }
\author{Logan Hunt}
\date{\today}
\title{Homework 3}
\hypersetup{
 pdfauthor={Logan Hunt},
 pdftitle={Homework 3},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 28.2 (Org mode 9.5.5)}, 
 pdflang={English}}
\begin{document}

\maketitle

\section{Question 1 (3.21)}
\label{sec:orge5708f1}
\begin{center}
\includegraphics[width=.9\linewidth]{./img/representatives.png}
\end{center}

The state and congress\textsubscript{person} entities are just what was given in the requirements.

The relation between them - represent - describes which congress people are representatives in a certain state. The homework assumptions include the fact that a state has at most 53 representative congress people, and at minimum one. On the other side of the relationship, a congress person can only be a representative in one state.

Additionally, the bill entity was constructed from the requirements, and the relation "vote" describes, in addition with its own property "decision" which keeps the vote type from the congress person, the votes of each congress person.
As there are \(m\) bills, each congress person is required to have \(m\) votes, and each bill must have 435 votes from congress people.

Finally, a congress person sponsors either none or all of the bills (\(m\)), and each bill needs at least 1 sponsor and a maximum of 435.
\section{Question 2 (3.23)}
\label{sec:orgb0cbc0f}
\subsection{a) Strong Entities}
\label{sec:orge85bbf3}
\begin{itemize}
\item Bank
\item Loan
\item Account
\item Customer
\end{itemize}

\subsection{b) Weak Entities}
\label{sec:org5ae462d}
\begin{itemize}
\item Bank branch
\begin{itemize}
\item Partial key: Branch Number
\item Identifying relationship: "Branches"
\end{itemize}
\end{itemize}

\subsection{c) Constraints}
\label{sec:org7162d84}
\begin{itemize}
\item The participation of Bank-Branch in Branches is a total participation.
\item Cardinality ratio from bank to branches is 1:N.
\end{itemize}

\subsection{d) Relationships}
\label{sec:org5fbbd4e}
\begin{itemize}
\item Bank (1,n) <=Branches=> (1,1) Bank-Branch. A bank has at least one branch and a branch is only of one bank, hence the (1,1).
\item Bank-Branch (0,n) <=Accts=> (1,1) Account. A bank branch can have none or any number of accounts opened in it, but an account can only opened in one branch.
\item Acccount (1,n) <=A-C=> (0,m) Customer. An account can be owned by at least one customer (a joint account for married individuals is an example of more than one), and a customer can own either none or any number of accounts.
\item Bank-Branch (0,n) <=Loans=> (1,1) Loan. A bank branch can have none or any number of loans taken out in it, but a loan can only be taken out in one branch.
\item Loan (1,n) <=L-C=> (0,m) Customer.
\end{itemize}

\subsection{e) Requirements}
\label{sec:org0cce2c4}
A bank is an entity with a unique code, a name, and address. A bank must have one or more branches at some address. Together with the bank's code and branch number, a branch can be uniquely identified.

Branches have the ability to create accounts of any account type, and also have a tracking balance and unique account number. Any number of customers can participate in owning the account, but it must be at least one customer. However some customers may end up with no accounts.

Customers also have the ability to take out any number of loans, with an amount lent and type of loan included with a unique loan number, including zero. However, any loan that is taken out must have at least one customer owning it.

\subsection{f) Further Restrictions}
\label{sec:orgc3396fe}
To support only letting a customer take out two loans at a time, the relation L-C should be updated: Loan (1,n) <=L-C=> (0,2) Customer. 

To support only letting a branch take out a maximum of 1000 loans at a time, the relation Loans should be updated: Bank-Branch (0,1000) <=Loans=> (1,1) Loan. 

\section{Question 3 (3.24)}
\label{sec:org4cdca4d}
\begin{center}
\includegraphics[width=.9\linewidth]{./img/employee-departments-phones.png}
\end{center}

If each of every employee's has-phone relationship is fully contained in the employee's departments then the two relationships has-phone and contains are redundant because one could query all the departments an employee works for to get that employee's "phones".

\section{Question 4 (3.25)}
\label{sec:org8a15543}

\begin{center}
\includegraphics[width=.9\linewidth]{./img/teaches-course-text.png}
\end{center}

A ternary relationship would not fit because a text can only be used in one course and a course can only be instructed by one instructor.

Adopts would have the following cardinality constraint: Instructor (0, 20) <=Adopt=> (1,1) Text - as an instructor can teach two to four courses and each course can have 0 to 5 texts, an instructor can end up adopting 0 texts, or 5 unique texts for all 4 of their courses. But, as a text can only have one course, and a course can only be taught by one teacher, a text must be adopted by one and only one teacher.
\end{document}