Answers.Body: <p>Having spoken to our hosting experts we are going to rebuild foreign keys. Will update you shortly.</p>
  
  <p>thanks,
  Jon-man</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-06T19:09:15.327Z
Answers.Text: Did you ever end up getting them rebuilt? I am having a similar issue. Any help with doing that would be great.
Answers.UserDisplayName: Sleewok
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-14T13:31:48.553Z
Answers.Text: Yes @Sleewok we got this fixed by getting them rebuilt. It took us a while to idenitify this, but the problem usually occurs when a site is migrated.
Answers.UserDisplayName: Jon-man
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-01T09:00:11.513Z
Answers.LastActivityDate: 2016-03-01T09:00:11.513Z
Answers.UserDisplayName: Jon-man
Body: <p>At a client of us we have a problem with the database scheme. CiviCRM is working normally except that when you want to merge contacts the Activities/Groups/Relationships etc.. are missing in the merge screen.</p>
  
  <p>After some investigation it turns out the merge functionality use the mysql databasescheme for fin ding out which tables are linked to a contact.</p>
  
  <p>It does so with the query below:</p>
  
  <pre><code>SELECT table_name, column_name
  FROM information_schema.key_column_usage
  WHERE referenced_table_schema = database() 
  AND referenced_table_name = 'civicrm_contact' 
  AND referenced_column_name = 'id';
  </code></pre>
  
  <p>The problem at this specific installation is that the information_scheme.key_column_usage is empty for this specific database.</p>
  
  <p>So I assume that the foreign key relationships are missing in mysql. In the past this civicrm site has moved databases from one to another and there has been an update from 4.5.x to 4.6.x</p>
  
  <p>Does anyone know how to fix the database scheme? </p>
  
  <p>Thanks</p>
  
Tags: <database>
Title: Database scheme corrupt - foreign key relationships are missing in mysql
ThreadText: # Database scheme corrupt - foreign key relationships are missing in mysql
  
  (Asked by: username_0 on 2016-02-26)
  
  At a client of us we have a problem with the database scheme. CiviCRM is working normally except that when you want to merge contacts the Activities/Groups/Relationships etc.. are missing in the merge screen.
  
  After some investigation it turns out the merge functionality use the mysql databasescheme for fin ding out which tables are linked to a contact.
  
  It does so with the query below:
  
  ```
  SELECT table_name, column_name
  FROM information_schema.key_column_usage
  WHERE referenced_table_schema = database() 
  AND referenced_table_name = 'civicrm_contact' 
  AND referenced_column_name = 'id';
  
  ```
  
  The problem at this specific installation is that the information\_scheme.key\_column\_usage is empty for this specific database.
  
  So I assume that the foreign key relationships are missing in mysql. In the past this civicrm site has moved databases from one to another and there has been an update from 4.5.x to 4.6.x
  
  Does anyone know how to fix the database scheme?
  
  Thanks
  
  **Tags:** database
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-03-01. Score: 1
  
  Having spoken to our hosting experts we are going to rebuild foreign keys. Will update you shortly.
  
  thanks,
  username_1
  
  > **Comments:**
  > **username_2**: Did you ever end up getting them rebuilt? I am having a similar issue. Any help with doing that would be great.  
  > **username_1**: Yes @username_2 we got this fixed by getting them rebuilt. It took us a while to idenitify this, but the problem usually occurs when a site is migrated.  
  
  ---
  
  