I have two tables component, and component_type_text. Now, I have a POST request /components/text, which would insert a new record into the component_type_text table. The problem is, that components is the overcategory table for each specific component type. So this table would hold the component_id, type, and some other columns/attributes that are common across components.
So obviously, when performing this POST request, I would also somehow need to insert a record into the component table, as this is the "parent". And it is also used for other endpoints, for example DELETE /components/{id}.
What I thought about doing is, keeping the post requests as is /components/text, /components/button, and so on and then set up a trigger on the PostgreSQL database which inserts records into the components database once an insert happened on any components_type_* table.
Now the problem is that with this solution, I could not let the user pass custom attributes to the parent component table, which are the same across all the component_type_* tables. An example would be custom_styles, which every component could have.
I could have the custom_styles attribute defined in each different type table, but that would be against the rules of normalisation in SQL and not ideal.
Does anyone have an idea how I should handle this database/api design?