If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Disable Foreign key checks.....

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-09, 06:38
tamilcnu tamilcnu is offline
Registered User
 
Join Date: Jan 2009
Posts: 3
Disable Foreign key checks.....

Hi Friends,
I am working with MySQL, InnoDB as a database. I will want to disable FOREIGN KEY checks. For that, I appended "?sessionVariables = FOREIGN_KEY_CHECKS = 0" to My Application's JDBC URL. i.e.,
URL= jdbc:mysql://MyHost/MyDB?sessionVariables = FOREIGN_KEY_CHECKS = 0
It is working fine before deployment. But after deployment it is not working( Foreign key checks are not disabled).
If foreign keys are enabled, then the problem is: child is inserting data before the parent table. So please get rid out of this.

Thanks for your reply,
Sreenivasulu.A.
Reply With Quote
  #2 (permalink)  
Old 01-23-09, 06:43
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Why can't you insert the record into the parent table first..?
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 01-23-09, 06:51
tamilcnu tamilcnu is offline
Registered User
 
Join Date: Jan 2009
Posts: 3
Manually I can insert the data into parent table, but My java application uses a large database. Whenever user adds a record into the database, number of queries tried to hit the database. If foreign keys are not there, then my application inserts data correctly. Because my application maintains relations in it's own fashion. When foreign keys are there, that time problem came.
Reply With Quote
  #4 (permalink)  
Old 01-23-09, 07:04
tamilcnu tamilcnu is offline
Registered User
 
Join Date: Jan 2009
Posts: 3
Question Java Apps and Foreign keys problem....

Hi Friends,
I am working with MySQL, InnoDB as a database. I will want to disable FOREIGN KEY checks through my jdbc application. For that, I appended "?sessionVariables = FOREIGN_KEY_CHECKS = 0" to My Application's JDBC URL. i.e.,
URL= jdbc:mysql://MyHost/MyDB?sessionVariables = FOREIGN_KEY_CHECKS = 0
It is working fine before deployment. But after deployment it is not working( Foreign key checks are not disabled).
If foreign keys are enabled, then the problem is: child is inserting data before the parent table. So please get rid out of this.

Thanks for your reply,
Sreenivasulu.A.
Reply With Quote
  #5 (permalink)  
Old 01-23-09, 07:08
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
if you are implementing your own RI checks (seems madness in the current day and age,but each to their own) have ypu thought of using the MyISAM engine.

or, a wild thought

rewriting your app so it writes to parent tables first?
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #6 (permalink)  
Old 01-23-09, 07:15
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
...even if it writes only the bare-minimum information (i.e. the primary key)
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 01-23-09, 07:19
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Originally Posted by tamilcnu
If foreign keys are not there, then my application inserts data correctly.
If it's not creating the parent records first then your application is NOT inserting data correctly. You should change your application.
Reply With Quote
  #8 (permalink)  
Old 01-23-09, 08:05
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Threads merged - please do not post the same question twice!
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On