duangenshi9836 2014-01-22 13:17
浏览 20
已采纳

访问者计数器的MYSQL数据库表结构[关闭]

I have a userbase on db

______________________________________________
id | Name | so many details | Unique page link
______________________________________________
1  | abc  | bla bla         | username

So, user abc have a page xyz.com/username

I want to show user abc stats about visitors i.e. like
1 jan - 400
2 jan - 350
and so on for last 7 day
and also the month wise record for last 12 months
jan - 49009
feb - 73849

what would be the best MYSQL database table structure design.

 _________________________________________________________________
    user id | day 1 | day2| and so on for 7 day | Jan | Feb | Mar
    ______________________________________________________________
    111111  |  400  | 300 |                     | 4250|24534|2435

I thought of something like this - is it OK or other optimized design is there?

  • 写回答

3条回答 默认 最新

  • dongyashun2559 2014-01-22 13:35
    关注

    You don't want to do it your way because you will have a long calender for each user.
    It will get out of hand quickly.

    You would want to have a table containing:


    ID | user_id | time_stamp | info


    1 | 324 | 2014/1/22 | 300


    2 | 327 | 2014/1/20 | 500


    3 | 324 | 2014/1/19 | 900

    Than when you want the info.

    Select * FROM table where user_id = 324 Would return


    ID | user_id | time_stamp | info


    1 | 324 | 2014/1/22 | 300


    3 | 324 | 2014/1/19 | 900


    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大