Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting VFP data to SQL Server data
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01438777
Message ID:
01438806
Views:
38
>>>
>>>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.

Thank you, Borislav. I will reread your message tomorrow when I am less tired.
"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
Previous
Reply
Map
View

Click here to load this message in the networking platform