How to implement a one-to-one relation in pgAdmin 4 using the ERD tool

October 10, 2025

Entity-Relationship Diagrams (ERDs) are powerful tools for database design, helping you visualize the structure of your data. A fundamental concept in ERDs is the relationship between entities, and one of the most common is the one-to-one (1:1) relationship. In this blog, we'll learn how to create a one-to-one relation using an ERD tool in pgAdmin 4.


What is a one-to-one relation?


A one-to-one (1:1) relation is a fundamental concept in database design where a record in one table is associated with exactly one record in another table, and vice versa. It creates a unique, bidirectional link between two entities. For example, a user and a user profile, a user account may have a separate profile with additional details (like a bio or preferences). Each user has one profile, and each profile belongs to one user.


Creating a one-to-one relation in pgAdmin 4


Let's dive into how we can create a 1:1 relation in pgAdmin 4 using the ERD tool.


Open the ERD canvas


To open ERD, select a database and choose ERD Tool from the tools menu.


Define entities


Let's define the two entities that will be part of the relationship. In our example, these are User  and UserProfile.

User Entity: This entity will hold core user data. It should have a primary key, such as userID. Other attributes might include username and email.

UserProfile Entity: This entity will contain supplementary user information. It also needs a primary key, which we will call profileID. Attributes could include firstName and lastName.


Establish the Relationship


To establish the 1:1 relation there are two approaches:

  1. This is the most common approach. We will add a userID column to the UserProfile table. This userID column will be a foreign key that references the userID primary key in the User table, to ensure it's a one-to-one relationship, this foreign key must also have a UNIQUE constraint.
  2. In this approach we will make the primary key of the UserProfile table as the foreign key that references userID primary key in the User table.

We will be focusing on the first approach. Select the UserProfile table and click on 1-1 button on the toolbar it will open a dialog for establishing 1:1 relation.


In the above dialog we can select the local column and define which approach we want to use by selecting either primary or unique constraint default is unique constraint.
After providing all the details click on the Save button and a 1:1 relation will be created between the two tables.

In the above diagram, you can see a 1:1 relation is created between the User and UserProfile table.

Conclusion

A 1:1 relation can help with performance and data isolation. The ERD tool in pgAdmin 4 can be used to create a 1:1 relation between two tables.
 

Share this