The demand is like this.
There is a data post that is written to the data table on the hour of the hourly.
Now you need to query on a monthly basis, such as at this point (assuming the current is 11:08), then the data is from September 1 0000 to September 6 1100 of all data.
Now there are 2 questions.
1. How should the data tables be designed for this scenario?
2. If the statistics are based on a month, such as the statistics by January 2015, How should the SQL statements be written?
Now I'm doing this, I'm going to write each hour's data into Table A (the fields are Id,time,order_count, where time is the UNIX timestamp format, which is written in PHP through the Times () function), The sum of the data in table A is then written to data table B and finally queried by data table B.
Thank you in advance for the prawns.
Reply content:
The demand is like this.
There is a data post that is written to the data table on the hour of the hourly.
Now you need to query on a monthly basis, such as at this point (assuming the current is 11:08), then the data is from September 1 0000 to September 6 1100 of all data.
Now there are 2 questions.
1. How should the data tables be designed for this scenario?
2. If the statistics are based on a month, such as the statistics by January 2015, How should the SQL statements be written?
Now I'm doing this, I'm going to write each hour's data into Table A (the fields are Id,time,order_count, where time is the UNIX timestamp format, which is written in PHP through the Times () function), The sum of the data in table A is then written to data table B and finally queried by data table B.
Thank you in advance for the prawns.
You this is a relatively simple statistics bar ... Do not know the need to draw a wave map not ~,
Everybody else. Every hour of data is given to you. You don't have to go by the hour alone. Data summary,
You just have to save every hour of data.
The table structure is basically
Id,data,time
Data is the value
Time is the timestamp of the data at which point in time 小时整
, i.e.忽略分钟
The query is indexed by time.