# Homework 6 March, 2022 1. **Tic-Tac-Toe:** Create a new version of tictactoe game by refactoring your previous code. The Goals of this task are: - Become familiar with symfony/console library. - Use OOP principles to organize your code. - Apply the concepts of psr-1 and psr-4 to organize your classes. - Showcase the usage of abstraction by using/defining interfaces. 2. **Research ACID:** https://en.wikipedia.org/wiki/ACID Today's exercise database and queries ```sql CREATE TABLE payments ( customer_name varchar(128), processed_at date, amount int ); CREATE TABLE balances ( username varchar(128), balance int ); CREATE TABLE large_table ( random_int int ); INSERT INTO payments VALUES ('clement', '2019-12-15', 10); INSERT INTO payments VALUES ('antoine', '2020-01-01', 100); INSERT INTO payments VALUES ('clement', '2020-01-02', 10); INSERT INTO payments VALUES ('antoine', '2020-01-02', 100); INSERT INTO payments VALUES ('antoine', '2020-01-03', 160); INSERT INTO payments VALUES ('simon', '2020-02-05', 1000); INSERT INTO payments VALUES ('antoine', '2020-02-01', 100); INSERT INTO payments VALUES ('clement', '2020-02-03', 10); INSERT INTO payments VALUES ('meghan', '2020-01-12', 86); INSERT INTO payments VALUES ('meghan', '2020-001-13', 70); INSERT INTO payments VALUES ('meghan', '2020-01-14', 90); INSERT INTO payments VALUES ('alex', '2019-12-11', 16); INSERT INTO payments VALUES ('clement', '2020-02-01', 10); INSERT INTO payments VALUES ('marli', '2020-01-18', 1); INSERT INTO payments VALUES ('alex', '2019-12-15', 10); INSERT INTO payments VALUES ('marli', '2020-01-25', 10); INSERT INTO payments VALUES ('marli', '2020-02-02', 10); INSERT INTO balances VALUES ('antoine', 0); INSERT INTO balances VALUES ('clement', 1000); ``` ```sql -- Sum the number of payments for each user. SELECT customer_name, count(customer_name) AS count FROM payments GROUP BY customer_name ORDER BY count DESC; -- Sum the payment amounts for each month. SELECT sum(amount) AS sum, extract(year from processed_at) as year, extract(month from processed_at) AS month FROM payments GROUP BY month, year ORDER BY sum DESC; -- Sum the payment amounts for each month for each user. SELECT customer_name, sum(amount), extract(year from processed_at) as year, extract(month from processed_at) AS month FROM payments GROUP BY customer_name, month, year ORDER BY customer_name DESC; -- Find the largest single-user payments for each month. SELECT max(amount), year, month FROM( SELECT customer_name, sum(amount) as amount, extract(year from processed_at) as year, extract(month from processed_at) as month FROM payments GROUP BY customer_name, month, year ) AS monthly_sums GROUP BY year, month; ```