There is a need, such as the customer upload the previous Excel table or CSV file, import user table, is the user information, including the following columns: Nickname, city, birthday, order number, mobile number, etc.
But in our system, the existing User table fields are only nicknames, cities, etc., no birthdays, order numbers, cell phone numbers and other fields.
Can the client upload a file, read the table file and create a new table to store the field information that was not in the user's table?
Or do you serialize the field information that you don't already have into a specific field in the original user table? When rendering in the foreground, format this specific field and display it?
Which is more feasible, or is there any other way?
Reply content:
There is a need, such as the customer upload the previous Excel table or CSV file, import user table, is the user information, including the following columns: Nickname, city, birthday, order number, mobile number, etc.
But in our system, the existing User table fields are only nicknames, cities, etc., no birthdays, order numbers, cell phone numbers and other fields.
Can the client upload a file, read the table file and create a new table to store the field information that was not in the user's table?
Or do you serialize the field information that you don't already have into a specific field in the original user table? When rendering in the foreground, format this specific field and display it?
Which is more feasible, or is there any other way?
If the custom field is not sorted, the need to retrieve, or it is recommended to use large pieces of bar, the data of non-standard fields are all in JSON or array serialization format into a large piece, need to show the time to do formatted output.
If you have a sorting or retrieval requirement, you may need to combine some open source indexing software such as Apache Lucene to achieve the specific requirements.
There is another way, the code may logically be slightly more complex, storage efficiency will be very low, in fact, it is not recommended, but if you are not a huge amount of data, the problem is not big. The method is to create a sufficient number of tables (User_data), the field naming is common naming methods such as "Column1,column2" and so on, and then specifically set up a table to do the user's data field corresponding (User_data_columns), the format is as follows:
| UID | name | field |
| 101 | Birthday | Column1 |
| 101 | Mobile Phone number | Column5 |
To use, first read the corresponding field name and table field in the User_data_columns table, and then go to the User_data table to fetch the corresponding column data.