Which kind of tables do you have? InnoDB tables enforce foreign key integrity, MyISAM tables do not. From the manual <http://dev.mysql.com/doc/mysql/en/CREATE_TABLE.html>:

| In MySQL 3.23.44 or later, InnoDB tables support checking of foreign key
| constraints. ... For other storage engines, MySQL Server parses the
| FOREIGN KEY and REFERENCES syntax in CREATE TABLE statements, but without
| further action being taken.

You can check the types of your tables with SHOW CREATE TABLE or SHOW TABLE STATUS.

Michael

Zachary Agatstein wrote:

A very simple question:

If I have a table A with PRIMARY KEY K,
and table B which has a column C defined as a FOREIGN KEY F referencing table A.K,


then, I would expect, C can only take a value from those already existing in table A column K.

So, let's assume, for simplicity's sake, table A has only 1 column K which is integer, and row are: 1, 3, 6, 7.

Would it be logical to assume that the column C of the table B cannot have a value of 2, because no such value exists in A.K?

For some reason, in my database no such rule seems to be enforced.

Do you know why?

Thanks.

ZA



-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to