OHDSI Home | Forums | Wiki | Github

Foreign Keys Error

I have successfully run the DDL, loaded all the Vocabulary CSVs from Athena, applied the Primary Keys, and Indexes on SQL Server.

Unfortunately, I continue to run into a problem when trying to apply the foreign keys:

Description Resource Path Location Type
SQL Error [1776] [S0000]: There are no primary or candidate keys in the referenced table ‘CDM.COHORT’ that match the referencing column list in the foreign key ‘fpk_COHORT_DEFINITION_cohort_definition_id’. Script-6.sql /General/Scripts Unknown Database Script Problem
SQL Error [547] [23000]: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “fpk_CONCEPT_ANCESTOR_ancestor_concept_id”. The conflict occurred in database “OMOP”, table “CDM.CONCEPT”, column ‘concept_id’. Script-6.sql /General/Scripts Unknown Database Script Problem
SQL Error [547] [23000]: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “fpk_CONCEPT_ANCESTOR_descendant_concept_id”. The conflict occurred in database “OMOP”, table “CDM.CONCEPT”, column ‘concept_id’. Script-6.sql /General/Scripts Unknown Database Script Problem
SQL Error [547] [23000]: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “fpk_CONCEPT_RELATIONSHIP_concept_id_1”. The conflict occurred in database “OMOP”, table “CDM.CONCEPT”, column ‘concept_id’. Script-6.sql /General/Scripts Unknown Database Script Problem
SQL Error [547] [23000]: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “fpk_CONCEPT_RELATIONSHIP_concept_id_2”. The conflict occurred in database “OMOP”, table “CDM.CONCEPT”, column ‘concept_id’. Script-6.sql /General/Scripts Unknown Database Script Problem
SQL Error [547] [23000]: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “fpk_CONCEPT_SYNONYM_concept_id”. The conflict occurred in database “OMOP”, table “CDM.CONCEPT”, column ‘concept_id’. Script-6.sql /General/Scripts Unknown Database Script Problem

Any help would be greatly appreciated!!!

@Sanjay_Udoshi:

You may want to also show folks those ALTER TABLE statements. Or you try finding out what’s going on with the help of your DB admin group. This Forum is probably not the best place to debug things in your environment. There are dozens of successful SQL Server installations, the likelihood this is due to a faulty script on Github is fairly low. Sorry for not giving you anything better.

1 Like

No worries, Christian! Thanks for your guidance as usual :slight_smile: I’ll hunt down an answer over on the DB Admins group.

-S

t