Programming instructions
54 Lesson 1 Preparing to Build the Sample Application
Establishing a relationship between the two tables
When the user selects an event type from the list obtained from reading the eventtypes 
table, the correct event type must be saved to the trips table with all the other trip related 
data. The application could store the eventType (for example, mountain climbing) itself 
into the eventType column in the Trips table. But if the name Mountain Climbing were 
later shortened to Climbing in the eventtypes table, new mountain climbing trips would 
be classified differently than ones saved before the change. For this reason and to save 
space in the database, the key to the eventtypes row (eventTypeID) is stored in the trips 
table instead. 
The two tables are said to have a relationship. This relationship works by matching data 
in key fields. In this case, the matching fields consist of a primary key (eventTypeID) 
from the Eventtypes table, which provides a unique identifier for each record, and a 
foreign key (eventType) in the Trips table. The foreign key contains the same value as the 
primary key, pointing to a unique event type. The following figure shows this 
relationship:










