Author: Pablo Valdunciel
Date: 07/09/2022
-
Uniqueness of the username: the inclusion of the
UNIQUE
constraint for the username does not seem appropriate, since two people can easily have the same name, especially if it is a common name. In a real scenario, theUNIQUE
constraint should be applied to theusername
in any case, since the username is usually used as an alternate primary key. -
Including the
TVShow
table. When it comes to representing Enums in databases, there are two possibilities:- Inserting a table containing the possible values of the Enum and adding a foreign key in the main table.
- Inserting a string column in the main table
The decision can be made based on how much space each of the two approaches takes up. In general, it is better to insert an additional table if the enum has few values, so the string column would have many repetitions.
In this task, I chose the fastest to implement option, which is to simply insert a string column, and ignored the space complexity issue.
First, create a virtual environment and activate it.
python -m venv .venv
source .venv/bin/activate # (Linux) .venv/Scripts/activate (Windows)
Second, install the dependencies.
pip install -r api/requirements.txt
Finally, start the FastAPI app.
cd api
python run.py
The API is available at localhost:8080/.
Execute the following commands. To do so, it is necessary to have Docker and Docker Compose installed.
docker-compose build
docker-compose up
The API is available at localhost:8080/.
The tests can be found in the test/
folder. To run the tests, execute the following commands:
cd api
python -m pytest ./test/
Once the FastAPI app is running, the documentation is available under localhost/8080/redoc