Integrity constraint violation using relationships

I’m using Libre Base and get the error below when I try to put a relationship between two tables. How do I fix this

If the computer is right, you need a fitting row in your TBL Rova Issues, if not you need to do a bug-report.

There is no value ‘63’ in “TBL Rova Issues”.“TOPIC ID”, but the entry exists in “TBL Rova Notes”.“JOIN TOPIC ID”.
All values, which appear in “TBL Rova Notes”.“JOIN TOPIC ID”, should also appear in “TBL Rova Issues”.“TOPIC ID”.

That did it thanks

Elaborating on what @Wanderer and @RobertG already explained (assuming that I correctly understand the purpose of your data structure) :
You seem to have entered notes for one issue #63 (child table being “TBL Rova Notes”), but it looks like an issue with #63 is not yet entered in “TBL Rova Issues” (which seems to be the parent side of the relationship). Child has no parent. First check that issue #63 is really entered.

A recurring situation where this happens is when the relationship key fields are textual, and the cause is leading or trailing spaces in one of the key fields. Whenever possible, the “TOPIC ID” primary key should be strictly numeric (some form of integer or “recordID” data type), and the “JOIN TOPIC ID” foreign key should be of the same (or compatible) data type. If the ID fields are numeric text fields, look for spaces before/after the digits.

Sometimes the displayed error also occurs with data type mismatch.

I found the fields in the notes table not connected to the issue in the main table which solved the problem.

thanks

1 Like

A side note on establishing relationships on empty database vs. entering data first:
Active relationships invoke additional processing to enforce data integrity. This will delay data entry.

  • For manual entry, the delay will usually be insignificant (even unnoticeable).
  • For batch data import from external sources, the accumulated delay may be significant.

A “best practice” for building a new database is to import preexisting data (with known integrity) first, then establish relationships before the database goes to “production state”/manual entry.

Missed your first reply

Sorry about the noise!

If you will, tick the answer from @RobertG or @Wanderer (whichever helped you most) as the solution, to tag your issue as solved.

Sorry not familiar with how to tick an answer.

Use the icons below the posts in this thread:
Screenshot_20240707-193809-01