官术网_书友最值得收藏!

Relationships

Relationships identify associations between the data stored in different tables. Entities relate to other entities in a variety of ways. Table relationships come in several forms, listed as follows:

  • A one-to-one relationship
  • A one-to-many relationship
  • A many-to-many relationship

A one-to-one relationship

A one-to-one relationship represents a relationship between entities in which one occurrence of data is related to one and only one occurrence of data in the related entity. For example, every employee should have a payroll record, but only one payroll record. Have a look at the following diagram to get a better understanding of one-to-one relationships:

A one-to-many relationship

A one-to-many relationship seems to be the most common relationship that exists in relational databases. In the one-to-many relationship, each occurrence of data in one entity is related to zero or more occurrences of data in a second entity. For example, each department in a Department table can have one or more employees in the Employee table. The following diagram will give you a better understanding of one-to-many relationships:

A many-to-many relationship

In a many-to-many relationship, each occurrence of data in one entity is related to zero or more occurrences of data in a second entity, and at the same time, each occurrence of the second entity is related to zero or more occurrences of data in the first entity. For example, one instructor teaches many classes, and one class is taught by many instructors, as shown in the following diagram:

A many-to-many relationship often causes problems in practical examples of normalized databases, and therefore, it is common to simply break many-to-many relationships in to a series of one-to-many relationships.

主站蜘蛛池模板: 龙山县| 泸西县| 都安| 达拉特旗| 灵武市| 上高县| 陕西省| 台山市| 泸定县| 河东区| 十堰市| 迭部县| 山阴县| 博爱县| 天门市| 揭阳市| 承德市| 如皋市| 侯马市| 锡林浩特市| 阳春市| 烟台市| 社旗县| 通城县| 定远县| 二连浩特市| 吉木萨尔县| 精河县| 云阳县| 内乡县| 汉沽区| 延吉市| 衡水市| 双峰县| 桐庐县| 南郑县| 庐江县| 油尖旺区| 芦山县| 吕梁市| 梁平县|