k3forx / fastapi-todo-app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logical design of database

k3forx opened this issue · comments

Database name

  • todo_app

Table names

  • priorities
  • tasks

Schema

  • priorities
Field Type Null Key Default Extra
id int(11) NO PRI NULL auto_increment
pririty varchar(255) NO NULL
created_at datetime NO NULL
updated_at datetime NO NULL
  • tasks
Field Type Null Key Default Extra
id int(11) NO PRI NULL auto_increment
title varchar(30) NO NULL
description varchar(1000) NO NULL
priority_id int(11) NO NULL
due_date date NO NULL
created_at datetime NO NULL
updated_at datetime NO NULL
completed_at datetime YES NULL
❯ docker-compose up -d
Creating network "fastapi-todo-app_default" with the default driver
Creating mysql ... done

❯ docker exec -it mysql bash
root@796966febc2b:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| todo_app           |
+--------------------+
5 rows in set (0.00 sec)

mysql> USE todo_app;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SHOW TABLES;
+--------------------+
| Tables_in_todo_app |
+--------------------+
| priorities         |
| tasks              |
+--------------------+
2 rows in set (0.00 sec)

mysql> SELECT * FROM priorities;
+----+----------+---------------------+---------------------+
| id | priority | created_at          | updated_at          |
+----+----------+---------------------+---------------------+
|  1 | high     | 2021-07-01 15:08:57 | 2021-07-01 15:08:57 |
|  2 | medium   | 2021-07-01 15:08:57 | 2021-07-01 15:08:57 |
|  3 | low      | 2021-07-01 15:08:57 | 2021-07-01 15:08:57 |
+----+----------+---------------------+---------------------+
3 rows in set (0.00 sec)

mysql> SELECT * FROM tasks;
+----+------------------+---------------------------------------+-------------+------------+---------------------+---------------------+--------------+
| id | title            | description                           | priority_id | due_date   | created_at          | updated_at          | completed_at |
+----+------------------+---------------------------------------+-------------+------------+---------------------+---------------------+--------------+
|  1 | Shopping         | buy eggs                              |           1 | 2021-07-08 | 2021-07-01 15:08:57 | 2021-07-01 15:08:57 | NULL         |
|  2 | Homework         | solve math problems                   |           1 | 2021-07-02 | 2021-07-01 15:08:57 | 2021-07-01 15:08:57 | NULL         |
|  3 | Prepare document | create documents for the next meeting |           2 | 2021-08-01 | 2021-07-01 15:08:57 | 2021-07-01 15:08:57 | NULL         |
|  4 | Change home      | preview new home                      |           3 | 2022-07-01 | 2021-07-01 15:08:57 | 2021-07-01 15:08:57 | NULL         |
+----+------------------+---------------------------------------+-------------+------------+---------------------+---------------------+--------------+
4 rows in set (0.00 sec)

mysql> exit
Bye
root@796966febc2b:/# exit
exit