There is a requirement, such as uploading a previous excel or csv file to the user table, which is user information, including the following columns: nickname, city, birthday, order number, mobile phone number, etc, however, in our system, the existing user table has only the nickname, city, etc., no birthday, order number ,... there is a requirement, such as uploading a previous excel or csv file to the user table, which is user information, including the following columns: nickname, city, birthday, order number, mobile phone number, etc,
However, in our system, the existing user table only has fields such as nickname, city, birthday, order number, and mobile phone number.
Can I ask the customer to read the table file and create a new table to store the field information that is not in the User table when uploading a file?
Or is there a specific field stored in the original user table after the field information is serialized? When the front table is present, Format this specific field and display it?
Which one is more feasible, or is there any other way?
Reply content:
There is a requirement, such as uploading a previous excel or csv file to the user table, which is user information, including the following columns: nickname, city, birthday, order number, mobile phone number, etc,
However, in our system, the existing user table only has fields such as nickname, city, birthday, order number, and mobile phone number.
Can I ask the customer to read the table file and create a new table to store the field information that is not in the User table when uploading a file?
Or is there a specific field stored in the original user table after the field information is serialized? When the front table is present, Format this specific field and display it?
Which one is more feasible, or is there any other way?
If the custom fields are not sorted and need to be retrieved, we recommend that you use a large field to store all the data of non-standard fields in JSON or array serialized format into a large field, you just need to format the output when you need to display it.
If you have sorting or retrieval requirements, you may need to use some open-source indexing software, such as Apache Lucene, to achieve this. See the specific requirements.
There is another way, the Code logic may be a little more complicated, and the storage efficiency will be very low. In fact, it is not recommended, but if you are not using massive data, the problem is not big. The method is to create a table (user_data) with enough fields. The field names are generally named like "column1, column2, create a table to correspond to user data fields (user_data_columns) in the following format:
| Uid | name | field |
| 101 | birthday | column1 |
| 101 | mobile phone number | column5 |
When necessary, read the corresponding field names and table fields from the user_data_columns table, and then retrieve the data of the corresponding column from the user_data table.