Describe the requirements:
Now we need to design the database table structure. There are many types of rules. How to design tables to store these rules. Each rule has common attributes and different attributes. At present, I have thought of two methods: the first is through foreign keys (common attributes are in one table, and the different attributes of the rules are placed in another table); the second is through wide fields (the different attributes of the rules are placed in a large field Save it);
May I ask the masters if there is a more efficient way.
Simple, JSON strings are stored in the database
The person above is right, you can directly save it as a json string! It is also convenient to operate
Now mysql5.7 explains the JSON series operation functions in Mysql in detail
In short, don’t try to extract what is common. .