Category: SQL


Defining generated columns with PostgreSQL and TypeORM

On this blog, we’ve covered a variety of different column types. So far, we’ve performed various operations on said columns such as and to modify the data directly. In this article, we cover generated columns that work differently. Generated columns in PostgreSQL We call the above columns generated because PostgreSQL automatically computes their data based […]


The basics of database normalization with TypeORM and PostgreSQL

Database normalization is a term often used when discussing database architecture design. Unfortunately, it is often presented with the use of complex definitions that make it difficult to grasp. In this article, we explain what normalization is and provide examples using TypeORM and PostgreSQL. Database normalization aims to improve the integrity and reduce the redundancy […]

JavaScript NestJS SQL TypeScript

API with NestJS #53. Implementing soft deletes with PostgreSQL and TypeORM

This entry is part 53 of 153 in the API with NestJS

In this series, we’ve implemented deleting functionalities for various entities. So far, it has always meant removing records permanently from our database. Instead, we can perform soft deletes. When we delete a record using a soft delete, we only mark it as deleted. You can find the code from this series in this repository. Soft […]

JavaScript SQL

Defining constraints with PostgreSQL and TypeORM

An important part of designing a database is controlling the data we store inside. The most fundamental way of doing that is defining the types for our columns. With that, we can make sure that a particular column holds only text, for example. In this article, we use constraints to have even more control of […]

JavaScript SQL

Range types in PostgreSQL and TypeORM

Sometimes when working with databases, we need to represent a range of values. For example, we might want to define a set of available numbers or a range of dates. One way to do that would be to create two columns that hold the bound values.

Above, we are using the timestamp with timezone […]

JavaScript Node.js SQL

Time intervals with PostgreSQL and TypeORM

In the previous article, we’ve looked into various ways to store the date and time with PostgreSQL and TypeORM. Postgres can also manage intervals. With them, we can store a period of time. Ways to store and display intervals in PostgreSQL There are various ways we can input and view interval values. By default, PostgresSQL represents […]

JavaScript SQL TypeScript

Managing date and time with PostgreSQL and TypeORM

While dealing with data, we often have to handle the date and the time. When doing so, there are quite a few things to consider. In this article, we approach various issues both from the standpoint of PostgreSQL and TypeORM. Ways to store and display date and time in PostgreSQL By default, Postgres represents dates […]

JavaScript NestJS SQL TypeScript

API with NestJS #16. Using the array data type with PostgreSQL and TypeORM

This entry is part 16 of 153 in the API with NestJS

Storing arrays is not an obvious thing in the world of SQL databases. Solutions such as MySQL, MariaDB, or Microsoft SQL Server don’t have a straightforward column type for arrays. This article explores how the array data type works in PostgreSQL both through SQL queries and through TypeORM. By learning how to operate on arrays […]