Hi!

>>>>> "Arjen" == Arjen G Lentz <[EMAIL PROTECTED]> writes:

<cut>

>> The problem is, how would you add a new bus and a new driver to the
>> database?  Whichever one is added first, you're going to get an error
>> because its counterpart doesn't exist yet, violating referential integrity.
>> 
>> You could always relax the NOT NULL constraint, but that might not be
>> desirable if you want to be consistent with the real-world situation that
>> your database describes.  Is there a way to update two tables at the exact
>> same time so that referential integrity never gets violated?

Arjen> You can do this by putting the two updates inside a transaction, using the
Arjen> InnoDB table type instead of MyISAM.
Arjen> No problem.

Note first that foreign keys can't be used to solve all problems of
references integrity as a foreign key can only refer to a primary key
in another table.

I am quite sure that the referential integrity is checked per
statement, not per transactions. (Which is a common thing in many
databases).

If this is the case, then you can't solve this by wrapping the updates
in two transactions.

Regards,
Monty

PS: Sorry, but I didn't have time to test this properly as I am
    answering this on my laptop...

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to