Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Foreign Key Constraint with No Check
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01554296
Message ID:
01554303
Vues:
32
>>Hi,
>>
>>I would like understand possibly side effects of applying a foreign key constraint with No Check. Here is why I am thinking of using FK constraint with No Check:
>>
>>I have to convert a customer database from VFP to SQL Server database. The VFP database has some entries (I don't know how much but I presume a good number) that are "orphaned." That is, if I do conversion with FK constraint in place I will get many records skipped that will not pass. So my strategy is to remove all FK constraints, convert the data from VFP to SQL and then add FK constraints with No Check. Therefore, if I understand correctly, the FK constrains will not be enforced on all existing records but only to the new records.
>>
>>So before I follow with this approach, I would like to know if there any negative ramifications from this approach.
>>
>>TIA for any suggestions.
>
>If you add constraints with NO Check, they will not be enforced for new rows either. E.g. you still will be able to insert orphans and other garbage. We actually have a lot of constraints with NO CHECK because we like to have default 0 value (or empty) instead of NULL when there is no relations. The down side is that you're not protected anymore.

Not sure what you mean by "not protected anymore". My understanding is that all new records added to the database will be checked; therefore, this protects from a user adding "bad" data. The old records will be seen by the user but if he/she want to change anything, they will get a message of "FK violation". So where am I not protected?
Thanks.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform