
Designing the database for your application
53
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:
Содержание COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION...
Страница 1: ...Getting Started Building ColdFusion MX Applications...
Страница 6: ...6 Contents...
Страница 10: ......
Страница 30: ...30 Chapter 2 CFML Basics...
Страница 36: ...36 Chapter 3 Database Fundamentals...
Страница 48: ......
Страница 76: ...76 Chapter 6 Lesson 2 Writing Your First ColdFusion Application...
Страница 134: ...134 Index...