After you have designed tables to store individual types of information, you must determine the relationships in those tables. In your final application you want to retrieve the information in a meaningful way. Usually the information that you retrieve from your database will consist of data stored in several tables. To enable you to get this data, C/SIDE uses relationships to link the tables that contain the related information.
Types of Relationships
Database terminology normally distinguishes between the following types of relationships:
-
One-to-Many
-
Many-to-Many
-
One-to-One
One-to-Many Relationships
In a one-to-many relationship, a record in Table 1 can have more than one matching record in Table 2, but a record in Table 2 can have no more than one matching record in Table 1. This is the most common type of relationship in a relational database.
Many-to-Many Relationships
In a many-to-many relationship, a record in Table 1 can have more than one matching record in Table 2, and a record in Table 2 can have more than one matching record in Table 1. This represents a problem in database design and may signal an inefficient design. Normally, you break down a many-to-many relationship into two one-to-many relationships.
One-to-One Relationships
In a one-to-one relationship, a record in Table 1 can have no more than one matching record in Table 2, and a record in Table 2 can have no more than one matching record in Table 1. This kind of relationship is inefficient and can often be avoided by combining the two tables.