Unix Technical Forum

Foreign key relationship

This is a discussion on Foreign key relationship within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi Im a sql newbie , and have created two tables with a foreign key relationship. How do i ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 05:25 PM
timmy_dale12@hotmail.com
 
Posts: n/a
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 ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 05:26 PM
John Bell
 
Posts: n/a
Default Re: 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



<timmy_dale12@hotmail.com> wrote in message
news:5bd31089.0308080131.14868339@posting.google.c om...
> 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 ?



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:11 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com