ER Diagrams   «Prev  Next»

Lesson 3Types of Relationships
ObjectiveDescribe the three types of Relationships

Three Types of Relationships in ERD Diagram

There are three types of relationships that can exist between two entities. An entity-relationship (ER) diagram can be created based on these three types, which are listed below:
  1. one-to-one relationship: In relational database design, a one-to-one (1:1) relationship exists when zero or one instance of entity A can be associated with zero or one instance of entity B, and zero or one instance of entity B can be associated with zero or one instance of entity A. (abbreviated 1:1)
  2. one-to-many relationship: (abbreviated 1:N) In relational database design, a one-to-many (1:N) relationship exists when, for one instance of entity A, there exists zero, one, or many instances of entity B; but for one instance of entity B, there exists zero or one instance of entity A.
  3. many-to-many relationship: In relational database design, a many-to-many (M:N) relationship exists when, for one instance of entity A, there exists zero, one, or many instances of entity B; and for one instance of entity B, there exists zero, one, or many instances of entity A. (abbreviated M:N)

1:n Relationship Explained

A 1:N relationship, often referred to as one-to-many, is a fundamental concept in relational database design. This type of relationship indicates that one record in a given table can be associated with multiple records in another table, yet a record in the second table can only be associated with one record in the first table. To elaborate, consider two tables, Table A and Table B. In a 1:N relationship, for every single record in Table A, there can be multiple corresponding records in Table B. However, each record in Table B can relate back to only one record in Table A. This is the premise of a one-to-many relationship.
For example, let's imagine Table A is a 'Customers' table, and Table B is an 'Orders' table in a retail database. Each customer (in the Customers table) may place multiple orders (in the Orders table). This establishes a one-to-many relationship from Customers to Orders. However, each order can be linked back to only one customer, maintaining the integrity of the 1:N relationship.
In the realm of table mappings, the 1:N relationship is implemented using a foreign key constraint. A foreign key is a field (or collection of fields) in Table B that uniquely identifies a record in Table A. The foreign key in Table B references the primary key of Table A. This creates a link from the many side (Table B, Orders) to the one side (Table A, Customers), enabling the establishment of the 1:N relationship.
The enforcement of the 1:N relationship in this manner maintains referential integrity in the database, ensuring that relationships between tables remain consistent and the data is reliable. It is crucial to accurately reflect the nature of the relationship between entities during the database design process to ensure the resultant database accurately models the system's requirements.
In summary, a 1:N relationship in the context of table mappings in database design represents a common relational association between two tables, where each record in the first table can relate to multiple records in the second table, and each record in the second table relates back to only one record in the first. This relationship is integral to creating efficient, accurate, and reliable database systems.

Following are simple examples of each:
1:1 relationship In a traditional American marriage, a man can be married to only one woman; a woman can be married to only one man.
1:N relationshipA child has exactly one biological father; a father can have many biological children.
M:N relationshipA student can enroll in many classes; a class can have many enrolled students.

In the business world, one-to-one relationships are few and far between. One-to-many and many-to-many relationships, on the other hand, are common. However, as will be explained later, many-to-many relationships are not permitted in a relational database and must be converted into one-to-many relationships. Relational databases are comprised almost entirely of tables in one-to-many relationships.

Save Time Writing

Types of Constraints

Limit the number of possible combinations of entities that may participate in a relationship set. There are two types of constraints:
  1. cardinality ratio and
  2. participation constraints.
Very useful concept in describing binary relationship types. For binary relationships, the cardinality ratio must be one of the following types:

1) One To One

one-to-one
An employee can work in at most one department, and a department can have at most one employee.

2) One To Many

one to many
An employee can work in many departments (>=0), but a department can have at most one employee.


3) Many To One

many-to-one
An employee can work in at most one department (<=1), and a department can have several employees.

4) Many To Many (default)

many-to-many
An employee can work in many departments (>=0), and a department can have several employees

The following page contains three diagrams describing the 3 relationship types implemented in Microsoft Access.
Three Relationships in MS Access.
Question: Within the context of data modeling, does the notation 1..* have the same meaning as 1:N for the mappings of tables?
In data modeling, different notations are often used to represent the relationships between entities (such as tables in a relational database). The notations "1..*" and "1:N" do, in fact, express the same type of relationship, albeit in different notational systems.
  1. "1..*" Notation: This is commonly used in UML (Unified Modeling Language) diagrams to denote a relationship. The "1.." signifies that one instance of an entity can be associated with zero or more instances of another entity. This notation allows you to specify both minimum and maximum cardinality. In this case, the minimum is one (at least one instance must exist) and the maximum is unspecified (denoted by ''), indicating any number of instances.
  2. "1:N" Notation: This notation, commonly used in ER (Entity-Relationship) diagrams, also signifies a relationship between two entities. The "1:N" means that for one instance of an entity, there can be zero, one, or more related instances of another entity. In other words, it denotes a one-to-many relationship.

While the notation differs, both "1..*" and "1:N" represent a one-to-many relationship between two entities. In the context of relational databases, this often translates to a primary key to foreign key relationship between two tables, where one row in the first table can correspond to multiple rows in the second table.
However, one subtle difference lies in the way they handle the lower limit of cardinality. In "1:N", it is usually assumed that the relationship can also be optional on the 'N' side, i.e., there may be instances of the first entity that are not related to any instance of the second entity. But "1.." explicitly states that at least one instance on the '' side must be associated. It's important to interpret and apply these notations within the specific conventions of the modeling methodology you are using.

The next lesson defines one-to-one relationships.
Ad Relational Database Design