I’m about to embark on a project where a user will be able to create their own custom fields. MY QUESTION – what’s the best approach for something like this?
Use case: we have medical records with attributes like first_name, last_name etc… However we also want a user to be able to log into their account and create custom fields. For instance they may want to create a field called ‘second_phone’ etc… They will then map their CRM to their fields within this app so they can import their data.
I’m thinking on creating tables like ‘field_sets (has_many fields)’, ‘fields’, ‘field_values’ etc…
This seems like it would be somewhat common hence why I thought I would first ask for opinions and/or existing examples.
This is where some modern schemaless databases can help you. My favourite is MongoDB. In short: you take whatever data you have and stuff a document with it. No hard thinking required.
If, however, you are in relational land, EAV is one of classic approaches.
I have also seen people do these things: