Currently, I am writing an application that collects data in multiple stages. Suppose the entity: person
. I might collect a portion of the data in one stage: name
, address
. And in some later state I might collect the supplementary the data: age
, gender
.
The data collected can vary for each stage.
I really prefer using non-nullable columns to ensure data availability, which applies to most of these columns. However, this seems rather difficult in the described situation, since to be created requires all non-null columns to contain data. (In addition, some columns should be nullable in some situations in the future).
My current plan
Make every column nullable and programmatically decide if all columns which are ought to be not null are actually not null. Possibly, this state could be saved in an extra column such as is_complete: boolean
.
My question
I am mostly curious to other references regarding this problem: has this or a similar problem been encountered before and how was it approached?
Generally, I am looking for alternative approaches to my current plan or wondering what issues I could encounter in this proposal.
I plan to use postgres or mysql. Approaches to eighter DBMSs are welcome. I have been considering a nosql approach due to its somewhat unstructured nature but would rather not use it. May it be relevant: I will likely be using a ORM for managing my entites (typeorm)
Any advice is greatly appreciated.