CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Foreign Keys Out of Control
Pages: [1]

Author Topic: Foreign Keys Out of Control  (Read 2036 times)

Matt2000

  • I post frequently
  • ***
  • Posts: 288
  • Karma: 27
    • http://www.ninjitsuweb.com
Foreign Keys Out of Control
April 17, 2008, 12:39:50 pm
It seems like every time I turn around, CiviCRM is hindering my progress due to unnecessary FK restraint.

Today I'm trying to mass import (via a CSV into phpmyadmin) a bunch of option values into the civicrm_option_value table, and I'm getting a FK error on the component_id table, even though every existing row is NULL, just like my import file. It seems this column is not being used, and still it has a FK restraint?

Are there any plans to reduce the number of FK restraints? Admittedly, I don't entirely understand their purpose, except to prevent errors, but anyone who's hacking the database directly should know enough not to cause irreparable damage.

I've coined a new term for these: Foreign Unnecessary CiviCRM Keys. But usually I just use the acronym.
Drupal/CiviCRM micro-blogging http://twitter.com/matt2000

Ninjitsu Web Development http://www.NinjitsuWeb.com/

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Foreign Keys Out of Control
April 17, 2008, 10:35:21 pm

foreign keys are your friend and will save you in quite a few instances. I dont think we'll ever reduce the number of FK restraints (2.0 introduced quite a few more constraints). We are also fans of strong typing and initializing variables before they are used :)

Can you cut-n-paste your sql insert statement which shows this error. the component_id is optional and hence can be NULL. ensure you dont include it in your insert statement

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Matt2000

  • I post frequently
  • ***
  • Posts: 288
  • Karma: 27
    • http://www.ninjitsuweb.com
Re: Foreign Keys Out of Control
April 17, 2008, 11:54:05 pm
I re-wrote the SQL to work around, and I don't think I can get back to the SQL that was generated by the phpmyadmin CSV import. It's possible that feature is buggy and phpmyadmin is to blame, but I run into FK errors so often in CiviCRM (mainly when upgrading), that it seems like something is not right.
Drupal/CiviCRM micro-blogging http://twitter.com/matt2000

Ninjitsu Web Development http://www.NinjitsuWeb.com/

mcsmom

  • I post frequently
  • ***
  • Posts: 266
  • Karma: 23
    • Official Joomla! Book
  • CiviCRM version: 4 and 3.4
  • CMS version: Joomla!
Re: Foreign Keys Out of Control
April 27, 2008, 01:15:11 am
I think it is the order that the tables are in when doing your backup.  Even when I back up with no foreign keys there are still always many places I have to stop and start because of FK when moving a civicrm database.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Foreign Keys Out of Control

This forum was archived on 2017-11-26.