I'm currently using MYSQL Workbench to design a database for a Joomla component and I've come across a stumbling block in the design.
Problem description:
I want to allow the admin to create fields for the front-end user to manage. The field is to be determined by the admin in terms of the type and length.
My design:
ADMIN_FIELDS (this is the table to store admin defined fields)
id INT
name VARCHAR(45)
type VARCHAR(45)
USER_FIELDS (this is the table to store user information in the fields defined by admin)
id INT
value LONGTEXT
admin_field_id FK_ADMIN_FIELDS
Questions:
Since I do not know the length of the value field, I've chosen LONGTEXT as the datatype. This could range from a boolean to a LONGTEXT size, depending on what the admin select as the datatype. Is this a good database design technique given my problem? Is there a better way?
Is there a performance hit if I use LONGTEXT for something as small as a boolean? In the worst case scenario, if the admin decides to go all out crazy with boolean on all fields of his site, and hypothetically speaking he has a billion users who creates these values. Will the site suffer a performance hit then?
If there is no performance hit, then why do we even bother to store data into relevant data type. Why not use LONGTEXT for everything?
Thanks in advance for your answer.