468,242 Members | 1,515 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

Foreign key constraints

Hi

I'm developing a DB using SQL server 2005 to b used in a data mining project, the data that will be worked with are constant and would not change or updated and more records will be add later. I created the tables and the relationship between them using the Database diagrams without writing any code.

I noticed that errors occurs in the data entry step so i changed a field value in the relationship dialoug box which is : "Enforce foreign key constraints" when i change the value to "No" the data entry process done smoothly.

I need to know wt does this field do? and if changing the values will effects the database.

Thanks alot,

Regards
Noora
Nov 16 '08 #1
1 1339
Delerna
1,134 Expert 1GB
Basically.....

Primary keys are used to uniquely reference any single record within a single table.

A foreign key is used to relate records in one table with records in another table.

A foreign key constraint ensures that you cannot have records in one table that do not have at least 1 related record in the other.

For example, you have an order header table and an order line table.
The order number might be the foreign key between the two tables

The foreign key constraint would ensure that you cannot have records in the order lines table for an order number that does not exist in the order header table.

Does that make sense?
Can you see now what you have done by turning the constraint off?

Regards
Nov 19 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by John Towell | last post: by
1 post views Thread by Jason Madison | last post: by
6 posts views Thread by Brendan Jurd | last post: by
13 posts views Thread by Bob Stearns | last post: by
reply views Thread by Rajesh Tiwari | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.