I had the opportunity to create a web application from scratch with Python, so as a summary! This article is about designing apps, designing and building databases.
Previous article [Python] Web application from 0! Hands-on (0) ~ Environment Construction --- Qiita
The goal is to create a web app with CURD functionality using HTML, CSS, JavaScript, Python, and SQL.
This time I would like to make a simple Todo app as a subject.
The required functions are
Let's say four. These acronyms are sometimes referred to as CRUD, and most business apps are based on these features. I created each screen image.
The registered Todo is displayed in a list format. There is a new add button, which opens the new registration form. You can edit and delete each line from the buttons located on each line.
This is Todo's new registration form. Enter a title and click the "Add" button to add it to the list.
This is Todo's edit form. Todo will be updated by updating the title and pressing the "Update" button.
If you press the delete button in the list, the data in the corresponding row will be deleted. At that time, a message asking if you want to delete it will be displayed, and if you press the "Delete" button, Todo will be deleted.
This is the only database design (laughs) The point is that by providing a column called is_deleted, it is possible to logically delete Todo. Logical deletion means that the data remains, but it appears to the user that it has been deleted by giving it a "disappeared or not disappeared" flag. It's a method. When deleting, set is_deleted = true and do not display the data for which is_deleted is true in the list.
Conversely, deleting data completely from a database with a SQL DELETE statement is called "physical deletion."
id: Todo ID (unique) title: The title of Todo created: The date and time when the Todo was created isDeleted: Is Todo deletedLet's actually make it from the database! pgAdmin4 is a tool that works in a browser. For Windows, type "pgadmin" in the search box on the menu bar and it should come up.
From here, it will be generated in the following order. Server Group-> Server-> Database-> Schema-> Table
First you need to create a server group for your database.
Select Object> Create> Server Group.
The name is "Todo Servers".
Next, create a server. Right-click on TodoServers> Create> Server.
The name is "Todo Server".
On the Connection tab Host name/address: localhost Password: postgres Please enter and save.
Then create the database. Right-click on TodoServer's Databases and select Create> Database.
Save it with the name "Todo Database".
Right-click Schemas> public> Tables in TodoDatabase and select Create> Table.
Name is "to do".
In the Columns tab, set the columns as shown in the image and save. (You can add it from the + button on the upper right)
Up to here for this time! We did a simple screen design, database design, and database construction for the app!
We will build the server side (Rest API)! [Python] Web application from 0! Hands-on (2) ~ Hello World ~ --Qiita
Recommended Posts