On Fri, 4 Jun 2004 09:39:44 -0300 (ART)
Leandro Melo <[EMAIL PROTECTED]> wrote:

> Hi,
> i`m using mysql in a j2ee application with JBoss.
> For best design practices i cannot add the
> foreign-keys to the tables in the same "insert" as i
> add the table data. Basically, i`ll add it a few
> milliseconds latter (in the same transaction), but
> anyway it`s not in the same "insert".

This doesn't sound like "best design practices".  What exactly are you trying to do?

Why not:

START TRANSACTION;
INSERT INTO table (nonfk_col1, nonfk_col2) VALUES ('x', 'y');
UPDATE table SET fk_col3 = fk_values WHERE whatever;
COMMIT;

> Then, i had to configure my foreign-keys to be allow
> null, something that i really don`t want to do.

Allowing foreign key columns to be NULL is a perfectly acceptable and reasonable 
practice depending on your data model. 

> So, is there a way to only check for the FKs
> constraint at the end of the transaction, and not at
> the rigth moment of the insert????

You could enable and disable foreign keys in your transaction but this seems to be 
hacking a solution onto a design problem.

Josh

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

Reply via email to