I’m currently working with a project. Now the issue arises is, I have to handle dynamic columns in database table.
I’ve a table Charges, where amount of different charges corresponding to each Client will be stored. Suppose this table has the following columns-
Client_Id Charge_1 Charge_2 Charge_3 Charge_4
Now, the administrator can apply more new Charges for clients. In that case, new charges will be added to the Charges table as column. And this need to be handled in application run time not in database design time. This is my thought.
But, it doesn’t look suitable to me.
Is there any better idea to handle this issue?? Please suggest me.
Thanks in advance. and I’m new with this database design.
Make a Composite table, i.e. ClientCharges
You could keep your original Charges Table and your Client table and in the Client Charges table have the following columns:
ClientChargeId, ClientId, ChargeId
In your Charges table you can keep adding (as many Charges are you require) and then reference the ChargeId in the ClientCharges table.
Then add foreign key constraints on the ClientId and ChargeId fields.