Wednesday, March 21, 2012

Primary Key Foreign Key Tables

Hi All,
i do have two table a Master and a Detail which has a primary
key on the Master Table and Foreign key on the Detail Table
How do i insist that when ever there is a entry in the Master table
there should atleast exist one record in the Detail Table. Any sort of
condition can be made
Thanks in advance
thomsonHave a look at BOL "Constraints" and "Foreign key constraints"
HTH
Gerard|||Circular references are complex in SQL. An easier way is to write a trigger
to check the existance of rows in the referencing table.
Anith|||This is typically handled best in a client application (e.g., an n-tier
object) as a business rule.
see the following link for some more thoughts on this:
http://expertanswercenter.techtarge...i976558,00.html
thomson wrote:

>Hi All,
> i do have two table a Master and a Detail which has a primary
>key on the Master Table and Foreign key on the Detail Table
>
>How do i insist that when ever there is a entry in the Master table
>there should atleast exist one record in the Detail Table. Any sort of
>condition can be made
>
>Thanks in advance
>thomson
>
>

No comments:

Post a Comment