Home All Groups Group Topic Archive Search About

Primary Key Foreign Key Tables

Author
21 Oct 2005 1:41 PM
thomson
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

Author
21 Oct 2005 2:02 PM
Gerard
Have a look at BOL  "Constraints" and "Foreign  key constraints"

HTH
Gerard
Author
21 Oct 2005 3:00 PM
Anith Sen
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
Author
21 Oct 2005 3:59 PM
Trey Walpole
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.techtarget.com/eac/knowledgebaseAnswer/0,295199,sid63_gci976558,00.html

thomson wrote:

Show quote
>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
>

>

AddThis Social Bookmark Button