Issue
I am currently developing a spring boot application with a database for patient data. I would really like to use spring's JPA as I am familiar with it but there is a problem I have with no satisfying solution for.
The problem is, we have several parameters to be store in DB. But in the future, these parameters might change and I would have to add new parameters and persist them in my DB. Unfortunately, I am not the person entering all the data by hand but just the person writing the application.
Is there any way to dynamically add a column on runtime and save into the database.
If not, I was thinking about another approach where instead of saving entries as follows:
| PatientID | param1 | param2 | param3 | ... |
I would save them like this:
| PatientID | ParameterType | Value | Date |
| 1 | param1 | 10 | 1.1.2021 |
| 1 | param2 | 15 | 1.2.2021 |
...
I would really appreciate any input you can give me, even completely different approaches
Solution
I would recommend you store document instead of entity. For that you can use Spring-data-couchbase because we don't know the data structure.
You can explore SQL vs noSQL
Answered By - Az.MaYo
Answer Checked By - Candace Johnson (JavaFixing Volunteer)