By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,806 Members | 1,837 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,806 IT Pros & Developers. It's quick & easy.

Foreign key constraints

P: 1
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
Share this Question
Share on Google+
1 Reply


Delerna
Expert 100+
P: 1,134
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.