I am developing a project that helps administrators store applications infrastructure information in one place. During planning phase I faced with problem how to store & process some components information in the best possible way.
For example, administrators can create an Application and add to it some Services like (Web App, Lambda, Win Service etc). To each Service administrator can assign Components of different types:
Approximate application hierarchy
I thought to create table called Components with columns like Id, ServiceId, Data, Type and store in Data field all component related data in JSON format converted to base64 and serialize/deserialize it each time when needed. The key idea that I am going to extend application later and would like to have possibility easily add new components without core code modifications.
Could you suggest some good approaches to achieve desired application behavior?
Thank in advance.
Your approach with json Data is already very extendable. It is enough to make a polymorphic handlers for json Data. And adding a new component will require only a new handler, without changing the database and the rest of the infrastructure.
However, it is better to store json not in base64 but in specially designed types like postgres jsonb. It's more efficient and easier to manipulate.
There are 3 small problems that can arise with this design.