Microsoft 9GD00001 Computer Accessories User Manual


 
190 Microsoft Visual Studio 2010: A Beginner’s Guide
TIP
Figure 7-7 shows an editable Relationship Name field. In many cases, you won’t
care what this name is because it follows a standard convention of FK_Child_Parent.
However, sometimes you have multiple relationships between the same tables, which
means that VS appends an incremental number to the end of the name. Thus, for
instance, the next foreign key relationship between the same two tables would be
FK_Child_Parent1. In those cases, it would be smart to plan ahead and change the
name to something meaningful so that you can later understand or quickly recall what
relationship rules the foreign keys are enforcing. To see what I mean by enforcing
rules, go ahead and enter a new record in the Order table, but enter an integer in the
CustomerID column that does not exist already in the Customer table, like 9999. Tr
y to
save that record and then read the error message presented to you.
Working with multiple tables, you might want to have a better feel for the database
structure and relationships. Database diagrams could be helpful in this case. T
o create a
database diagram, right-click the Database Diagrams folder under the database in Server
Explorer and click Add New Diagram. Click Yes when you receive an information
message requesting the creation of objects for database diagramming. In the Add
Table
window, press the
CTRL key so that you can select multiple rows, click to select each
table, and click Add. You’ll see a new database diagram similar to Figure 7-9 (you
may see Order appear above Customer in your diagram, which is fine; the position of
Figure 7-8 Foreign key relationship Save warning message