简体   繁体   中英

Database structure for affiliate system

I am creating an affiliate tracking system and am looking for the best database structure to use on mySQL for low load on the server.

There will be 1000 affiliates. Each affiliate will have stats per day.

I am thinking of this scenario. One main table for the affiliates:

Affiliates

id    affiliate_id    username    password    and so on (other affiliates details)
1     0000001         johndeer    password   

... and creating a new table for each affiliate which will have store his statistics like this:

Table name : affiliate-userid

Date        Clicks    sales    sale_price    total_earned    bonus
12/12/12    45        2        20            40              0
12/13/12    12        3        20            60              0  

So in this case each affiliate will have his own statistics table.

Is this correct or do I need to do something else?

Create two table

  • Affiliates(af_id(pk),*) and

  • Stats(stat_id(pk),af_id(fk),*)

Then, Refer Affiliates table in stats table. you can add any number of stats for any number of affiliates. No need to go for a table for each affiliate. It's a bad Idea.I think you understood.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM