Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting VFP data to SQL Server data
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01438777
Message ID:
01438787
Vues:
42
>>
>>Yes,
>>Maybe I didn't express myself clear.
>>Yes the Referential integrity must be done via the PARENT table primary key and Foreign Key in the Child Table(s).
>>BUT every table (no matter parent or child it is) SHOULD have Primary key.
>>
>>A very rough example why:
>>
>>Parent Table 
>>--------------------------
>>Id           Name
>>--------------------------
>>1            Example 1
>>2            Example 2
>>
>>
>>
>>Child Table 
>>--------------------------
>>ParentId     SomeOtherField
>>--------------------------
>>1            Example 1
>>1            Example 1
>>1            Example 1
>>
>>2            Example 2
>>
>>
>>As you see you have 3 records in the child table for the ParentID = 1.
>>And HOW you will UPDATE/DELETE only the FIRST of these records if you didn't have PK for that TABLE?
>
>I guess the confusion comes from what I am using as Primary Key. What I was referring to as Candidate key should be called the Primary key. Then what would I call my identity field? Just identity field?; I don't know. Or maybe I ought to redesign my database and use my identity field as primary key and have the same field (like identity in parent table) in the child table(s). Something to think about.
>
>Thank you very much for your help.


No,
Candidate key is a Field in the Child table that hold a PK value of the Parent table.
So RI should be build based on PK of the Parent Table and FK in Child Table.

Candidate Key could NOT be an Identity field, just because you can't synchronize tables that well (even when the Child table should have only one record matching parent table) , do not need to mention that the Child table can have more than one record matching Parent table.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform