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

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.

主站蜘蛛池模板: 南丰县| 兰西县| 舒兰市| 金沙县| 元朗区| 钦州市| 沙河市| 武川县| 玉溪市| 天台县| 密山市| 泽州县| 石渠县| 宝应县| 南宫市| 汝阳县| 馆陶县| 宜宾市| 衡水市| 建宁县| 佛山市| 双牌县| 沾益县| 皮山县| 泰和县| 德格县| 电白县| 吴堡县| 绍兴市| 郯城县| 北碚区| 璧山县| 克东县| 陵水| 买车| 长武县| 襄汾县| 宜良县| 临武县| 南京市| 乌海市|