Skip to content

Conditional relationships (?) #890

Closed Answered by dantownsend
zarch asked this question in Q&A
Discussion options

You must be logged in to vote

I think your suggested solutions make sense.

To me, the options which I like the most are probably:

Nullable foreign keys

Having a bunch of nullable foreign keys, and you assign the relevant one. The downside is you end up with lots of foreign keys if you have a lot of protocols, but not the end of the world.

You have a single protocol table, with JSON data

Just as you suggested in your last approach. It means you can a single foreign key, and store the information about the particular protocol in a JSON field.

A small hint - use JSONB instead of JSON if possible, it's better for querying that plain JSON.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zarch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants