Statistics of members' half-year repurchase rate (7 days, 15 days, 30 days)

order order form field id order_no (order number) business_id (merchant ID) user_id (member ID) money (consumption amount)
user membership table id name member name
business merchant form id name merchant name

cardinality: 200merchants A merchant may have 200customers
premise: members buy once, second purchase is considered repurchase
question: are there any good designs and ideas

the method I have come up with at present:
create a new table and save the relationship between merchants and members

re_business_user

< table > < thead > < tr > < th > business_id < / th > < th > user_id < / th > < th > number < / th > < th > money < / th > < th > date < / th > < th > created_at < / th > < / tr > < / thead > < tbody > < tr > < td > merchant ID < / td > < td > user ID < / td > < td > number of purchases < / td > < td > purchase amount < / td > < td > time (2018-05-11) < / td > < td > creation time < / td > < / tr > < / tbody > < / table >

every day, when a merchant buys goods, users query whether the re_business_user data exists (add date equal to the current time 2018-05-11 in the where condition). There is no new one-day record. If there is, update the purchase times + 1 and increase the purchase amount
so that I can quickly calculate the 7-day repurchase rate, 15-day repurchase rate and 30-day repurchase rate

.

this design will result in a large amount of data in the whole table, and there will be about 120W of data in a month (200 200 30)

do you bosses have any good ideas to solve this problem? Thank you

Mar.14,2021

ahem, first of all, I think 120w is not big (habit of complaining). Then since you are segmented, it would be better to build an index directly. Of course, if you optimize, it would be better to create a new table record.
in fact, I personally understand that there are two situations in the use of a database, one is to trade space for time, and the other is to trade time for space. If it is me, the individual will choose to just optimize the index of the table, and then query, considering that the frequency of your repurchase rate survey will not be very high, it is OK to use time as a cost.

Menu