Chapter 2

Entities andRelationships

2.1    Foreign Keys and Relationships between Tables

When a database is designed correctly, information about different kinds of entities is stored in separate tables. The relationships between the entities in different tables are as important as the attributes of the entities themselves. The Actor and Role tables, as introduced in Chapter 1, contained no information telling which actor played which role. In contrast, Table 2.1 shows the Role table expanded to include an actorID column, which captures the relationship between the Actor and Role tables.

TABLE 2.1 Role

img

Given a Role table containing an actorID ...

Get The SQL Programming Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.