Can not create relation in Base

Trying to create a new relation in Base between two tables I get following error. Have no idea what this means. Please help:

SQL Status: 23000
Error code: -177

Integrity constraint violation - no parent 2, table: RelationsTable2 in statement [ALTER TABLE “RelationsTable2” ADD FOREIGN KEY (“CID”) REFERENCES “CenterData” (“ID”)]

The error code presented refers to inserting NULL’s into a field. Are you getting this error on the creation of the relation or when trying to enter data? Was there data in the tables before attempting this? Posting the table structures and exactly what you are linking would be of help.

I assume you are trying to create a one to many relationship between CenterData, the one side, and RelationsTable2, the many side, and ID in CenterData is the unique Primary Key. Do you have data in these tables when you try to create the link? If so the error suggests that you have orphaned records in RelationsTable2. Have you deleted some records in CenterData so some values of ID no longer exist but records containing this value for CID are still in the RelationsTable2? The error you get suggests this is the case - there are records in RelationsTable2 with no parent, i.e. with no ID value for the records that have this CID value. If this is the case you need to delete the records in RelationsTable2 that contain the CID values that no longer exist in CenterData.

Thank you so much for clarifying this. There are indeed orphant records (the only thing not thought of yet). I will locate these, ‘clean up’ and see what happens.

@Denko did deleting orphaned records solve the problem?