Types Of Relationships In Database
1. One-to-One (1:1) Relationship
In one to one relationships, a record is present in one table along with its corresponding existing relation, and the vacant relation among the records is present in another table. The type of relationship we are talking about is not as usual, and it is normally used when two entities that belong to a specific set need to be stored independently for normalization or security purposes. In another case, a person’s employees’ data consists of a record in the “personal details” table in a human resources database.
2. One-to-Many (1:N) Relationship
A relationship where the items from one table can be linked to only one or many items from another table is called a one-to-many relationship; in some cases, one item from the first table correlates with only one item from the second table. This connection becomes very strong in that it is particularly used to describe situations where one object can be linked to many similar or identical objects. For example, in an online store backend database, every customer may place multiple orders, yet the master customer record stays the same. If a record has more than one order, these are obtained from the backend database.
3. Many-to-Many (N:M) Relationship
The duality of a many-to-many relationship is characterized by the presence of multiple records belonging to a table in association with multiple records from another table. The interconnection of these relationships follows a junction table format, which is the component that holds both tables together. In the many-to-many relationship model, a wide variety of complex relationships can be established where each entity has many related entities. Such a database for a music streaming service could have a table representing each track that belongs to multiple playlists, and each of them could contain multiple tracks.
What is Relationship in DBMS?
A database is a structured data set that is usually electronically written in a computer system and stored as data. With their primary purpose being to maintain, keep, and extract data correctly, databases are important. In many practical situations, data is never an isolated file, and its correlations may be hidden. The occurrence of patterns in data is important to identify for effective data management. Here enters the word of data relationships in databases.