CodePudding user response:
If you only need to record views, to create a table about video:create table vedio_info (
Id int auto_increment primary,
Vedio_name varchar (200) not null,
Click_times int the not null default 0
)
Every time someone clicks video + 1:
update vedio_info
The set click_times=click_times + 1
Where id=xx
If is detailed record of every click details:
create table vedio_click (
Id int auto_increment primary,
Vedio_name varchar (200) not null,
User_id int the not null,
Click_dt timestamp not null
)
Each click will insert a record, the need to query the number of video statistics once line:
select vedio_name, count (*)
The from vedio_click