Questions about how PHP is stored and how efficient it is

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.