1. <legend id='I4Wt6'><style id='I4Wt6'><dir id='I4Wt6'><q id='I4Wt6'></q></dir></style></legend>
        <bdo id='I4Wt6'></bdo><ul id='I4Wt6'></ul>
    2. <tfoot id='I4Wt6'></tfoot>
        <i id='I4Wt6'><tr id='I4Wt6'><dt id='I4Wt6'><q id='I4Wt6'><span id='I4Wt6'><b id='I4Wt6'><form id='I4Wt6'><ins id='I4Wt6'></ins><ul id='I4Wt6'></ul><sub id='I4Wt6'></sub></form><legend id='I4Wt6'></legend><bdo id='I4Wt6'><pre id='I4Wt6'><center id='I4Wt6'></center></pre></bdo></b><th id='I4Wt6'></th></span></q></dt></tr></i><div id='I4Wt6'><tfoot id='I4Wt6'></tfoot><dl id='I4Wt6'><fieldset id='I4Wt6'></fieldset></dl></div>

        <small id='I4Wt6'></small><noframes id='I4Wt6'>

      1. 用于按日、周、月、年保存统计数据的数据库结构

        Database structure for holding statistics by day, week, month, year(用于按日、周、月、年保存统计数据的数据库结构)
      2. <tfoot id='nULRu'></tfoot>

            <i id='nULRu'><tr id='nULRu'><dt id='nULRu'><q id='nULRu'><span id='nULRu'><b id='nULRu'><form id='nULRu'><ins id='nULRu'></ins><ul id='nULRu'></ul><sub id='nULRu'></sub></form><legend id='nULRu'></legend><bdo id='nULRu'><pre id='nULRu'><center id='nULRu'></center></pre></bdo></b><th id='nULRu'></th></span></q></dt></tr></i><div id='nULRu'><tfoot id='nULRu'></tfoot><dl id='nULRu'><fieldset id='nULRu'></fieldset></dl></div>
              <tbody id='nULRu'></tbody>
            • <small id='nULRu'></small><noframes id='nULRu'>

              <legend id='nULRu'><style id='nULRu'><dir id='nULRu'><q id='nULRu'></q></dir></style></legend>
                <bdo id='nULRu'></bdo><ul id='nULRu'></ul>

                  本文介绍了用于按日、周、月、年保存统计数据的数据库结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我必须按网站用户活动的天数、周数、月数和年数收集统计数据.我是数据库设计阶段,我想正确地完成这个阶段,因为它会让我的编码生活更轻松.

                  I have to collect statisctics by days, weeks, months and years of user activity for a site. I am the DB design stage and I wanted to do this stage properly since it will make my coding life easier.

                  我要做的只是在每次活动发生时将数据库中字段中的值加 1.这样我就可以每天、每周、每月和每年拉出日期.我的数据库应该如何构建?抱歉,如果这对大多数人来说是一个简单的问题.如果这种结构可以扩展以便可以分解为其他类别,那也是很棒的.

                  What I have to do is just simply increment the values in the fields by 1 in the DB each time an activity happens. So then I can pull up the date by each day, each week, each month and year. How should my DB be structured? Apologies if this is a simple question for most. It would also be great if this structure could be extendable so that it can be broken down by other categories.

                  我遇到的问题是每个月都由更多天组成,而这些日子在每个日历年都发生变化.

                  The bit am having trouble with is each month is made up of more days and these days change each calender year.

                  感谢大家的帮助或指导.

                  Thanks all for any help or direction.

                  其他信息:Linux 机器,使用 PHP 和 MySQL

                  Other info: Linux Machine, making use of PHP and MySQL

                  推荐答案

                  无需更新每天、每周等的计数,只需在每次活动发生时向表中插入一行,如下所示:

                  Instead of updating counts per day, week etc. just INSERT a row into a table each time an activity happens like this:

                  insert into activities (activity_date, activity_info) 
                  values (CURRENT_TIMESTAMP, 'whatever');
                  

                  现在您的报告非常简单,例如:

                  Now your reports are very simple like:

                  select count(*) from activities
                  where activity_date between '2008-01-01' and '2008-01-07';
                  

                  select YEARWEEK(`activity_date`) as theweek, count(*)
                  group by theweek
                  

                  这篇关于用于按日、周、月、年保存统计数据的数据库结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)
                    <tbody id='GfdR4'></tbody>
                • <i id='GfdR4'><tr id='GfdR4'><dt id='GfdR4'><q id='GfdR4'><span id='GfdR4'><b id='GfdR4'><form id='GfdR4'><ins id='GfdR4'></ins><ul id='GfdR4'></ul><sub id='GfdR4'></sub></form><legend id='GfdR4'></legend><bdo id='GfdR4'><pre id='GfdR4'><center id='GfdR4'></center></pre></bdo></b><th id='GfdR4'></th></span></q></dt></tr></i><div id='GfdR4'><tfoot id='GfdR4'></tfoot><dl id='GfdR4'><fieldset id='GfdR4'></fieldset></dl></div>

                    <bdo id='GfdR4'></bdo><ul id='GfdR4'></ul>

                          • <small id='GfdR4'></small><noframes id='GfdR4'>

                          • <tfoot id='GfdR4'></tfoot>

                            <legend id='GfdR4'><style id='GfdR4'><dir id='GfdR4'><q id='GfdR4'></q></dir></style></legend>