V4.2.sql 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. -- 2020-06-01 用户短视频表
  2. CREATE TABLE `friendship`.`user_video` (
  3. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  4. `content` varchar(140) NULL COMMENT '文案',
  5. `user_id` bigint(20) NULL COMMENT '用户id',
  6. `create_time` timestamp(0) NULL COMMENT '创建时间',
  7. `status` tinyint(1) NULL COMMENT '状态',
  8. `video_cover` varchar(255) NULL COMMENT '视频封面',
  9. `video_url` varchar(255) NULL COMMENT '视频地址',
  10. PRIMARY KEY (`id`)
  11. ) ENGINE = InnoDB AUTO_INCREMENT = 11000011;
  12. -- 2020-06-01 话题标签表
  13. CREATE TABLE `friendship`.`topic_dictionary_info` (
  14. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  15. `topic_id` bigint(20) NULL COMMENT '话题id',
  16. `tag_id` bigint(20) NULL COMMENT '标签id',
  17. PRIMARY KEY (`id`) USING BTREE
  18. ) ENGINE = InnoDB AUTO_INCREMENT = 10312341 COMMENT = '话题关联字典标签信息表';
  19. -- 2020-06-02 黑名单
  20. CREATE TABLE `friendship`.`user_black` (
  21. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  22. `user_id` bigint(20) NULL COMMENT '用户id',
  23. `target_user_id` bigint(20) NULL COMMENT '目标用户id',
  24. `create_time` timestamp(0) NULL COMMENT '创建时间',
  25. PRIMARY KEY (`id`)
  26. ) ENGINE = InnoDB AUTO_INCREMENT = 10001000;
  27. -- 2020-06-04 小视频推荐表
  28. SET NAMES utf8mb4;
  29. SET FOREIGN_KEY_CHECKS = 0;
  30. DROP TABLE IF EXISTS `video_recommand`;
  31. CREATE TABLE `video_recommand` (
  32. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  33. `video_id` bigint(20) DEFAULT NULL COMMENT '视频id',
  34. `user_id` bigint(20) DEFAULT NULL COMMENT '用户id',
  35. `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  36. `video_url` varchar(256) DEFAULT NULL COMMENT '视频url',
  37. `video_cover_image` varchar(256) DEFAULT NULL COMMENT '视频封面',
  38. `logic_delete` tinyint(2) DEFAULT '0' COMMENT '是否逻辑删除:0:不删除:1:删除',
  39. PRIMARY KEY (`id`)
  40. ) ENGINE=InnoDB AUTO_INCREMENT=11001419 DEFAULT CHARSET=utf8mb4 COMMENT='小视频推荐表';
  41. SET FOREIGN_KEY_CHECKS = 1;
  42. -- 2020-0604 视频点赞
  43. CREATE TABLE `friendship`.`video_like` (
  44. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  45. `user_id` bigint(20) NULL COMMENT '用户id',
  46. `video_id` bigint(20) NULL COMMENT '视频id',
  47. `create_time` timestamp(0) NULL COMMENT '创建时间',
  48. PRIMARY KEY (`id`)
  49. );
  50. ALTER TABLE `friendship`.`video_like`
  51. ADD INDEX `idx_userid_videoId`(`user_id`, `video_id`) COMMENT 'userId和videoid建立联合索引';
  52. -- 2020-06-07 视频弹幕
  53. CREATE TABLE `friendship`.`video_barrage` (
  54. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  55. `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id',
  56. `video_id` bigint(20) NULL DEFAULT NULL COMMENT '视频id',
  57. `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '内容',
  58. `create_time` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  59. PRIMARY KEY (`id`) USING BTREE,
  60. INDEX `video_id`(`video_id`) USING BTREE COMMENT '为视频id添加索引'
  61. ) ENGINE = InnoDB AUTO_INCREMENT = 1008829 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '视频弹幕/评论表' ROW_FORMAT = Dynamic;
  62. -- 2020-06-12 用户短视频统计
  63. CREATE TABLE `friendship`.`user_video_statistics` (
  64. `id` bigint(20) NOT NULL COMMENT '主键',
  65. `video_id` bigint(20) NULL COMMENT '短视频id',
  66. `like_num` int(8) NOT NULL DEFAULT 0 COMMENT '点赞次数',
  67. `reward_num` int(8) NOT NULL DEFAULT 0 COMMENT '打赏次数',
  68. `comment_num` int(8) NOT NULL DEFAULT 0 COMMENT '评论次数',
  69. PRIMARY KEY (`id`)
  70. );
  71. ALTER TABLE `friendship`.`user_video_statistics` COMMENT = '短视频统计信息';
  72. ALTER TABLE `friendship`.`user_video_statistics`
  73. MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键' FIRST;
  74. -- 20200617
  75. CREATE TABLE `friendship`.`topic_user_black_list` (
  76. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  77. `topic_id` bigint(20) NULL COMMENT '话题id',
  78. `target_user_id` bigint(20) NULL COMMENT '目标用户id',
  79. `create_time` timestamp(0) NULL COMMENT '创建时间',
  80. PRIMARY KEY (`id`)
  81. ) ENGINE = InnoDB AUTO_INCREMENT = 10001110;