If you have no relational data knowledge or experience, this section is for you. If you are using LINQ to
SQL you will inevitably run into relational data environments (after all, that is what relational databases
are all about) and because you are mapping relational data objects (tables, and so on) to programming
language objects, you also need to take into account their relational data (primary keys and foreign keys).
There are, of course, complete books on how to effectively and efficiently design databases. For
example, the Wrox book Beginning Database Design covers design concepts including modeling and
209
Part III: LINQ to SQL
normalization. This section merely introduces the concepts of primary keys and foreign keys that are
used in relational databases.
Chapter 12 explores querying across relationships using LINQ to SQL in detail.
Primary Keys
A primary key is a column or a group of columns that uniquely identifies each individual row in a
database table. No columns included in the primary key can accept null values. A primary key enforces
the table??™s integrity and can be defined when the table is created, or later when modifying the structure
of the table.
Pages:
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346