Читать книгу Designing Geodatabases for Transportation - J. Allison Butler - Страница 39

Origin and destination tables

Оглавление

We have used the terms origin and destination to refer to the two classes participating in a relationship. It is very important that you know which is which, because it is easy to get it backward. You could lose data as a result of an identification error.

Figure 3.14 Origin and destination tables It may seem logical to treat the more important class as the origin, but that is usually the wrong thing to do. In this example, we seek to establish a relationship between a street class and a street name class. We have separated the names from the streets because we have a mixed-jurisdiction database that has several duplicated street names—sometimes with overlapping address ranges. The Street table is a valid combination of street name, address range, and community name. The address range and community name are stored directly in the Street table, but the street names are in a separate table. We need to create a relationship class to manage the one-to-many relationship between the Street and StreetName tables. Here are two approaches, one wrong, the other right.

In a one-to-many relationship, you will normally want the origin to be at the “one” end of the relationship. The top part of figure 3.14 shows a StreetHasName relationship between a Street table and a StreetName table. While it is certainly true that a street has a street name, this relationship is backward. The result of deleting a row in the Street (origin) table will be that the value of StreetNameID is set to null in the StreetName (destination) table. Suddenly, all Street table rows that pointed to that row no longer have a legitimate foreign key and the name disappears from all the streets that used it.

The lower part of figure 3.14 shows the right way to characterize this relationship as StreetNameIsAssignedToStreet. Now, if you delete a row in the Street able, nothing at all happens in the StreetName table. Of course, if you delete a row in the StreetName table, all the rows in the Street table that pointed to that street name no longer have a legitimate foreign key, but that is what needs to happen.

Designing Geodatabases for Transportation

Подняться наверх