Operation Manual

Understanding Databases
Linking tables
25
490 Crystal Reports User’s Guide
When you link, you are using a field that is common to both tables. Crystal
Reports uses the link to match up records from one table with those from the
other. In this example, the link assures that the data in each row of the report
refers to the same order.
Link from and link to
When you link two tables, you link from one table to another table. The from
table is used as a primary table, while the to table acts as a lookup table
where records are looked up by the primary table. In a simple link, the Report
Designer examines the first record in the primary table and finds all matching
records in the lookup table. Once all matches have been found in the lookup
table for the first record in the primary table, all matches in the lookup table for
the next record in the primary table are found.
Link relationships
When you link records from one table to another table, the records will
typically fall under one of two relationship types:
One-to-one
One-to-many
One-to-one relationships
In a one-to-one relationship between records in two linked tables, for every
record in the primary table there is only one matching record in the lookup table
(based on the linked fields). For example, in the Xtreme.mdb database, the
Employee table can be linked to the Employee Addresses table based on the
Employee ID field in each table. The Employee table contains information about
employees at the company, the positions they hold, their salaries, hiring
information, and so on. The Employee Addresses table contains each
employee’s home address. There is only one record for each employee in each
of these tables. Therefore, if the Employee table is linked to the Employee
Addresses table, only one record will be found in the Employee Addresses
table for each record in the Employee table. This is a one-to-one relationship.
One-to-many relationships
In a one-to-many relationship between records in two linked tables, for every
record in the primary table, there may be more than one matching record in
the lookup table, based on the linked fields. In the Xtreme.mdb database, the
Customer table can be linked to the Orders table based on the Customer ID
field in each table. The Customer table contains information about each