OHDSI Home | Forums | Wiki | Github

Applying Foreign Keys in SQL Server - ERRORS

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!!!

t