There is a database in which many tables have the same type field in which only 2 parameters (say 'car' : 'bike' ). How best to store these parameters ?:
1. Create a separate table and prescribe id
2. Create an enum field for each table).
- not understood. Do you have two parameters in one field? - Mike
- If one of the two - ENUM. If none, one or two - SET. - Akina
- not understood. Do you have two parameters in one field? - no, the field can be either car or bike - Murad
- If one of the two - ENUM. If none, one or two - SET. - the question was how best to store these parameters (in a separate table or to register in each enum) - Murad
|
1 answer
Everything depends on your business requirements:
When / If you need to add a value to
enumin a large and frequently used (millions of records) table. That will have to stop the application.If a separate table, then this is another table that must be contained (as well as
join's ...), which simply contains constants.As an option (second and a half), not perfect, you can put the constants in the code and leave a comment to the column what values mean what, but then the connection between the meaning and the meaning is lost. If you just watch the data, it is not clear what they mean without a code.
In short, you decide depends on the business goal.
- Thank you very much! Now within the framework of the project I have implemented it through the code + enum. The tables are not too large, but where these parameters are used a lot. Therefore, I think that it would be better to remake through a separate table (it will be clearer) - Murad
|