Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary Keys
Message
 
À
04/12/2000 14:32:01
Gerald McKinsey
Keystone Consulting Services, Inc.
Yorktown, Indiana, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00449014
Message ID:
00449018
Vues:
10
>I always thought the Primary Key meant one field...the ID you want to make Primary.
>
>However, I just ran into some examples in a book. They were making all ID's in a table "Primary". (This was a MS-SQL type book, so they showed the cute little picture of the "key", etc) So it looked like they were making the foreign keys in the table "keyed" also.
>
>What is the purpose of this? Or can I go back to the thinking that only the main id of the table is the Primary key?
>
>thanks,
>Dustin

In SQL Server, you can only have one primary key constraint (In SQL Server, they are called constraints). You can have multiple unique constraints on a table, buy only one primary key constraint.

A child table may have multiple foreign key constraints, as would happen in a join table (a table that serves to relate two other tables).

Now I believe a primary key constraint can be made up of multiple field in the table (ex. CustomerName and CustomerState). But I never do this. I always use surrogate primary keys, where the primary key is one field in the table that is unrelated to the data.

HTH
Chris McCandless
Red Sky Software
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform