Rule 2: One and Only One Trainer

[Previous] [Next]

Each horse must have exactly one trainer at any particular moment.

This rule is similar to rule 1, and you should implement it in the same way. (Figure 4-1 shows you that we've already implemented these rules in the sample application.) Figure 4-8 is another detail from Figure 4-1, this time with the relationship between horses and trainers in focus. Don't worry about the RaceEntrants table just now. We'll come back to it when we cover the implementation of rule 6.

click to view at full size.

Figure 4-8. This detail from the data model shows that there's a foreign key relationship between Horses and Trainers.

Figure 4-9 highlights the fact that the two tables are related through the FK_Horses_Trainers relationship between the Trainers.TrainerId and Horses.Trainer columns.

Rule 2 Is Set

Just about everything we said about the first rule goes for this one as well. The rule is well secured, and it's secured in the only place where there's no possible way around it—the database. What's more, we didn't need any code at all to secure the first two rules. We used declarations only.

Figure 4-9. This dialog box shows that the Horses and Trainers tables are related through a foreign key constraint named FK_Horses_Trainers and based on equality between the TrainerId column in the Trainers table and the Trainer column in the Horses table.



Designing for scalability with Microsoft Windows DNA
Designing for Scalability with Microsoft Windows DNA (DV-MPS Designing)
ISBN: 0735609683
EAN: 2147483647
Year: 2000
Pages: 133

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net