Home > database >  The small white ask everybody to give a recruit. Thank you
The small white ask everybody to give a recruit. Thank you

Time:10-25

I want to do a video on demand system, which requires the number of database records to watch video, video probably more than 100, refer to the more than 100 video database structure's what kind of? I began to want to add the name of the 100 video to the user group of the column and record each user sees the state of the video, but this irrational, obviously, bother everybody to give a recruit, only 20, thank you

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
  • Related