OHDSI / OHDSI/CommonDataModel

unresolvable fk cycles between concept and concept_class

Open
#706 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Question
Dominant language
HTML
Stars
1.1k
Forks
508
Avg merge
1h 30m
Merged PRs (30d)
3

Description

Howdy lovely CDM Community,

i am new to all this and i am in the process to create a bunch of python representations for the OMOP-CDM Model (https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models) .

Now i ran into a problem with the CDM schema leaving me scratching my head:

In 5.4 we have the table concept which has a NOT NULL-able foreign key that references concept_class

FK Col concept_class_id in concept: https://github.com/OHDSI/CommonDataModel/blob/main/ddl/5.4/postgresql/OMOPCDM_postgresql_5.4_ddl.sql#L422

FK definition: https://github.com/OHDSI/CommonDataModel/blob/main/ddl/5.4/postgresql/OMOPCDM_postgresql_5.4_constraints.sql#L156

At the same time we have a NOT NULL-able foreign key in concept_class that references concept

FK Col concept_class_concept_id in concept_class - https://github.com/OHDSI/CommonDataModel/blob/main/ddl/5.4/postgresql/OMOPCDM_postgresql_5.4_ddl.sql#L444

FK definition: https://github.com/OHDSI/CommonDataModel/blob/main/ddl/5.4/postgresql/OMOPCDM_postgresql_5.4_constraints.sql#L159

The problem is if i want to create a new row in concept i need an existing concept_class to reference but if i want to create concept_class i need an existing concept to reference but if i want to create a new concept... you get the point :)

How am i supposed to insert concept data without having some cumbersome scripts that will disable constraints under certain circumstances (which runs against the whole idea of having a data model with constraints in the first place)

I could not find any information on how to solve this in a cleanly manner. if anyone has any hints for me, I would be very grateful. cheers.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ddl/5.4/postgresql/OMOPCDM_postgresql_5.4_ddl.sql around lines 422 and 444, then inspect the corresponding foreign-key definitions around lines 156 and 159 in OMOPCDM_postgresql_5.4_constraints.sql. Determine whether the schema provides a supported insertion path that preserves both constraints; document the verified procedure or the required schema correction, with a reproducible example showing that concept and concept_class data can be inserted.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.