Types of Table Relationships
Table relationships come in several forms:
One-to-one relationships
One-to-many relationships
Many-to-many relationships
For example, suppose you have a table called employees that contains each person's Social Security number, name, and the department in which he or she works. Suppose you also have a separate table called departments, containing the list of all available departments, made up of a Department ID and a name. In the employees table, the Department ID field matches an ID found in the departments table. You can see this type of relationship in Figure 14.1. The PK next to the field name indicates the primary key.
Figure 14.1. The employees and departments tables are related through the DeptID key.
In the ...
Get Sams Teach Yourself PHP, MySQL® and Apache All in One 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.