Databases and Data Validation

Overview


At this point, we have much of the knowledge needed to build web applications. We have learned about the client-server model, HTTP, and RESTful APIs. We have also learned about server-side development and client-side development, and how to create client-side applications that communicate with the server. So far, however, our applications have been such that the data is not stored anywhere.

In this part, we look into using databases to store and retrieve data. We primarily look into using PostgreSQL, which is a popular relational database, although we briefly also peek at key-value databases. We also visit validating data, as ensuring the correctness of entered data is crucial in web applications, and learn about patterns for structuring code.

The structure of this part is as follows:

  • Interacting with a Database shows how to create a web application with a form that allows sending SQL queries to a PostgreSQL database, and also demonstrates how to access the PostgreSQL database through the container.
  • PostgreSQL and Postgres.js discusses the Postgres.js library and outlines its use in querying PostgreSQL.
  • Repository and CRUD Pattern introduces the repository pattern and discusses the CRUD pattern. The repository pattern is used for abstracting the database logic from the rest of the application, while CRUD is the generic pattern for creating, reading, updating, and deleting data.
  • Data Validation and Zod discusses the need for data validation, introduces a validation library called Zod, and shows how Zod can be used to validate data in a web application.
  • Layered Architecture continues with the theme of separating data and code, and presents layered architecture, which is a way to organize code into layers that each have their own responsibility.
  • Key-Value Databases and Deno introduces key-value databases, which are databases that store data as key-value pairs, and shows how to use Deno’s built-in key-value store Deno KV.
  • Databases and Deployment shows how deploy server-side applications that use a database and shows how to request a database from our own database server.
  • Databases Migrations shows how to use Flyway for evolving the database schema.
  • Overarching Project continues with the overarching project.

Finally, at the end of the part, there is a recap and feedback chapter that briefly summarizes the part and asks for feedback on the part.