PHP storage methods and efficiency issues
For example: User tables: Data that slows down updates, such as user names, passwords, regions, mobile mailboxes, etc. one-to-one relationships
Information table: Data-storage integration, ranking, and other updates to compare blocks
Hobby table: A user ID corresponds to multiple hobby type IDs one-to-many
Favorites Table: One user ID corresponds to multiple article IDs for one-to-many
I want to make a one-to-one relationship between the hobby table and the collection table.
For example, there are two fields in the table, one is the user's ID, one is a field of text type, and is stored in array mode.
Hobby type ID or article ID
Would you like to ask everyone, in this way? Please help me to solve the doubts according to the actual needs
------Solution--------------------
The original solution is easy to do!
Although without the kinetic energy of the relationship between "hobby" and "collection" , the new scheme is feasible
But it's not advisable.
Arrays cannot be placed directly into a table, so you need to have the process of serialization and deserialization or JSON encoding
The array is just a few IDs, and after you get the array, you need to query the IDs for what they represent.
Moreover, the original scheme is a two-way user--hobbies, hobbies--users can query to
The new scheme becomes one-way.
Moreover, whether it is serialization or JSON, it doubles the amount of data. It's not worth it from a storage point of view.