What do you think about mysql data redundancy?

how does mysql respond to changing requirements?
Let me give you an example of buying goods: send red packets to users after the order is paid; do you store the record of sending red packets separately or in the order table?
the order list should show how many red packets have been sent for this order, and be able to sort by the amount of red packets.

after a few days, the product says that after the payment of the order is issued, the user will be issued with gold coins. It is necessary to record how many gold coins have been issued and be able to sort them according to gold coins. How should mysql deal with such changes in product demand?

May.22,2021

question 1
in order to ensure future business scalability, it can also be called the purpose of convenient expansion, which is, of course, a sub-table. Follow a rule: the same business is the same table, but different businesses are open separately. When separated, sorting and summarizing is of course very simple.

question 2
just leave the data there. What else can I do? If you can't, just back up and delete the production environment.


should be stored in separate tables. For fields that are frequently used in the main table or need to be sorted, I choose to be redundant to the main table


personal opinion:

  1. A general table stores only the attribute fields that the corresponding entity has. In the corresponding example, the red packet record should store a separate table
  2. sometimes fields that need to be queried frequently or used for sorting can be considered for redundancy. In corresponding examples, red packet amounts may need to be considered for redundant storage in the order
  3. . In the
  4. example, an order corresponds to multiple red packet records. The field associated with the primary key of the red packet record in the order may try to use the character type to store a set of red packet id. (not sure whether it is appropriate)

I hope I can help you. Thank you

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36c3c-2b7b9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36c3c-2b7b9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?