473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 ?
Jul 20 '05 #1
1 6475
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

<ti**********@hotmail.com> wrote in message
news:5b**************************@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 ?

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Simon Bond | last post by:
Hi there, I should point out I am very new to MySql, im trying to learn what I can. Basically im using Navicat to work with my databases. When making a foreign key, i am asked to enter the...
26
by: pb648174 | last post by:
I have a table called BidItem which has another table called BidAddendum related to it by foreign key. I have another table called BidFolder which is related to both BidItem and BidAddendum, based...
5
by: misscrf | last post by:
I have a database in 3rd normal form ( or pretty darn close) I have all of my reports working well, but the main report is having issues. This is for candidates applying for jobs. This report...
1
by: Jonathan Scott via AccessMonster.com | last post by:
I have an application who's backend has a relationship defined one to one. I need to update the LIVE version of the database to reflect this for the new version. How can I express such a foreign...
9
by: Jax | last post by:
I'm making my first ever database for my program. I understand the concept of one to many relationships but fail to see the advantage of using a secondary key over a primary one. I have a lot of...
7
by: am72de | last post by:
Hi all, I've posted this problem some weeks ago, but noone had a solution. Perhaps now someone could help me. I have the following tables: Create Table T1 ( ID1 int Not Null , ID2 int Not...
2
by: kal stevens | last post by:
I have been trying to write a database schema in mysql, and I cant figure this out. Here is a database schema DROP DATABASE IF EXISTS d; CREATE DATABASE d;
3
by: Steven | last post by:
Hello All, I am relatively new to database design and wanted to ask a few questions to see if I am on the right track regarding design and normalization. I am creating a user entity which is...
3
by: haiminnu | last post by:
I have created Two tables 1]EmployeeTable -------------------------- EmpID EmpName AccessLevelID ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.