one to one relationship


One to One Relation

A one-to-one relationship is a relationship where a record in one entity (table) is associated with exactly one record in another entity (table).

One to One Relationship (1:1): This is a relationship between two tables in which a single row of the first table can only be associated with one and only one record in the second table. In the same way, any row of the first table can be connected to any row of the second table. For example every country has one capital so this establishes a one to one relation between country and capital.

media queries

If there are two entities, 'Person' (Id, Name, Age, and Address) and 'Passport' (Passport id, Passport no), for example. As a result, each individual can only have one passport, and each passport can only belong to one person.

It's not very usual to have a connection like this. This type of interaction is, nonetheless, used for security reasons. We can easily save the passport id in the 'Person' database in the following example. However, we create a separate database for the 'Passport' because the passport number is potentially sensitive information that should be kept from some users. As a result, by creating a separate table, we can add an extra layer of security by limiting access to only certain database users.