创建 table 以计算每小时的访问量

Create table to count visits per hour

我需要计算一下,当我的客户创建帐户并在其中显示信息时,有多少次访问有一个应用程序,因此我的客户可以看到他们有多少次访问

我创建了一个 table 来存储整数,但我不确定这是否是正确的选择

CREATE TABLE tbHit(
intHit INT IDENTITY(1,1) NOT NULL,
intClient INT,
intYear INT,
intMonth INT,
intDay INT,
hr00 INT,
hr01 INT,
hr02 INT,
hr03 INT,
hr04 INT,
hr05 INT,
hr06 INT,
hr07 INT,
hr08 INT,
hr09 INT,
hr10 INT,
hr11 INT,
hr12 INT,
hr13 INT,
hr14 INT,
hr15 INT,
hr16 INT,
hr17 INT,
hr18 INT,
hr19 INT,
hr20 INT,
hr21 INT,
hr22 INT,
hr23 INT
)

我应该将所有访问存储在同一个 table 中,还是应该创建另一个 table 或其他方式来获得所有这些点击?

每次他们访问时,您都应该像这样在 table 中插入一行:

create table hits (id1 identity, 
customer_id  int,
visited_on datetime)

有日期和时间功能,如果您以这种方式存储,可以让您以任何角度(按天、小时、星期几)对命中进行切片和切块。

使用计算列并拆分为日期和时间以简化将来的查询

CREATE TABLE tbHit ( intHit    INT IDENTITY(1,1) NOT NULL
,                    intClient INT
,                    enter_date as convert(varchar(10),getdate(),113)
,                    enter_time as convert(varchar(10),getdate(),108) )