drop database if exists db_1;
create database db_1;
use db_1;
DROP TABLE IF EXISTS tb_user_video_log, tb_video_info;
CREATE TABLE tb_user_video_log (
id INT PRIMARY KEY AUTO_INCREMENT COMMENT '
⾃
增
ID',
uid INT NOT NULL COMMENT '
⽤
⼾
ID',
video_id INT NOT NULL COMMENT '
视
频
ID',
start_time datetime COMMENT '
开
始
观
看
时
间
',
end_time datetime COMMENT '
结
束
观
看
时
间
',
if_follow TINYINT COMMENT '
是
否
关
注
',
if_like TINYINT COMMENT '
是
否
点
赞
',
if_retweet TINYINT COMMENT '
是
否
转
发
',
comment_id INT COMMENT '
评论
ID'
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE tb_video_info (
id INT PRIMARY KEY AUTO_INCREMENT COMMENT '
⾃
增
ID',
video_id INT UNIQUE NOT NULL COMMENT '
视
频
ID',
author INT NOT NULL COMMENT '
创
作
者
ID',
tag VARCHAR(16) NOT NULL COMMENT '
类
别
标
签
',
duration INT NOT NULL COMMENT '
视
频
时
⻓
(
秒
数
)',
release_time datetime NOT NULL COMMENT '
发
布
时
间
'
)CHARACTER SET utf8 COLLATE utf8_bin;
INSERT INTO tb_user_video_log(uid, video_id, start_time, end_time, if_follow, if
(101, 2001, '2021-10-01 10:00:00', '2021-10-01 10:00:30', 0, 1, 1, null),
(102, 2001, '2021-10-01 10:00:00', '2021-10-01 10:00:24', 0, 0, 1, null),
(103, 2001, '2021-10-01 11:00:00', '2021-10-01 11:00:34', 0, 1, 0, 1732526),
(101, 2002, '2021-09-01 10:00:00', '2021-09-01 10:00:42', 1, 0, 1, null),
(102, 2002, '2021-10-01 11:00:00', '2021-10-01 11:00:30', 1, 0, 1, null);
INSERT INTO tb_video_info(video_id, author, tag, duration, release_time) VALUES