I am creating affiliate tracking system and looking for best database structure to use on MySQL to place the lowest possible load on the server. There will be 1000 affiliates, and each will have statistics per day. I am thinking of this scenario:
Affiliates (main table)
+----+--------------+----------+----------+--------------+
| id | affiliate_id | username | password | more columns |
+----+--------------+----------+----------+--------------+
| 1 | 0000001 | johndeer | password | |
+----+--------------+----------+----------+--------------+
I plan to create a new table for each affiliate with associated statistics:
AffiliateUser
+----------+--------+-------+-----------+-------------+-------+
| Date | Clicks | Sales | SalePrice | TotalEarned | Bonus |
+----------+--------+-------+-----------+-------------+-------+
| 12/12/12 | 45 | 2 | 20 | 40 | 0 |
| 12/13/12 | 12 | 3 | 20 | 60 | 0 |
+----------+--------+-------+-----------+-------------+-------+
Is this the correct design?
affiliate_idto the 2nd table and make the combination(affiliate_id, date)either the primary (or a unique) key, since you have stats per day per affiliate. – ypercube Dec 12 '12 at 6:22