Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Foreign key relationship
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 4th August 21:12
External User
 
Posts: 1
Default Foreign key relationship



Hi
Im a sql newbie , and have created two tables with a foreign key
relationship.

How do i insert into these tables. If i insert into the primary table
will the foreign key field in the second table be automaticly updated
by ms sql server ?
  Reply With Quote


  sponsored links


2 13th August 02:19
john bell
External User
 
Posts: 1
Default Foreign key relationship



Hi

If you are inserting data into the referenced table ("primary"!) then by
definition there will be no entries in the referencing table ("foreign
key"!). If you are entering data in the referencing table then there must be
a corresponding entry in the referenced table.

If you update the referenced fields in the referenced table, you will need
to specify UPDATE CASCADE on the foreign key definition to propagate the
changes. (See CREATE TABLE in Books online).

John
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666