Skip to content

Commit

Permalink
[perf] 调整db初始化sql
Browse files Browse the repository at this point in the history
  • Loading branch information
runs committed Jan 2, 2023
1 parent d5f5a21 commit 650e061
Showing 1 changed file with 70 additions and 60 deletions.
130 changes: 70 additions & 60 deletions database/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,90 +2,100 @@ create table bilbil_asoul_video
(
id bigint unsigned auto_increment
primary key,
bvid varchar(16) not null,
aid int unsigned not null,
name varchar(32) null,
mid bigint unsigned not null,
face varchar(255) not null,
tid int unsigned not null,
tname varchar(32) not null,
copyright int unsigned not null,
title varchar(128) not null,
`desc` varchar(1024) not null,
pic varchar(255) not null,
tag varchar(128) not null,
pubdate int unsigned not null,
duration varchar(64) not null,
view bigint unsigned default '0' not null,
danmaku bigint unsigned default '0' not null,
reply bigint unsigned default '0' not null,
favorite bigint unsigned default '0' not null,
coin bigint unsigned default '0' not null,
share bigint unsigned default '0' not null,
`like` bigint unsigned default '0' not null,
score bigint unsigned default '0' not null,
status tinyint default 1 not null,
created_at bigint unsigned not null,
updated_at bigint unsigned default '0' not null,
bvid varchar(32) not null,
aid bigint unsigned not null,
name varchar(32) not null,
mid bigint unsigned not null,
face varchar(255) not null,
tid int unsigned not null,
tname varchar(32) not null,
copyright int not null,
title varchar(255) not null,
`desc` varchar(2048) not null,
pic varchar(255) not null,
tag varchar(2048) not null,
pubdate bigint unsigned not null,
duration varchar(64) not null,
view bigint unsigned default '0' not null,
danmaku bigint unsigned default '0' not null,
reply bigint unsigned default '0' not null,
favorite bigint unsigned default '0' not null,
coin bigint unsigned default '0' not null,
share bigint unsigned default '0' not null,
`like` bigint unsigned default '0' not null,
score bigint unsigned default '0' not null,
status tinyint unsigned default '1' not null,
created_at bigint unsigned default '0' not null,
updated_at bigint unsigned default '0' not null,
constraint bilbil_asoul_video_bvid_uindex
unique (bvid)
);

create index bilbil_asoul_video_bvid_index
on bilbil_asoul_video (bvid);
create index bilbil_asoul_video_copyright_pubdate_score_index
on bilbil_asoul_video (copyright, pubdate, score);

create index bilbil_asoul_video_pubdate_index
on bilbil_asoul_video (pubdate);

create index bilbil_asoul_video_score_index
on bilbil_asoul_video (score);

create table bilbil_video_tag
(
v_id int not null,
tag varchar(16) not null,
v_id bigint not null comment 'video表id',
tag varchar(64) not null comment 'tag名称',
gmt_create datetime default CURRENT_TIMESTAMP not null,
gmt_modified datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP,
primary key (tag, v_id)
);

create table video_analysis
(
id int unsigned auto_increment
primary key,
type varchar(16) null,
`key` varchar(32) not null,
score bigint not null
);

create index video_analysis_key_index
on video_analysis (`key`);

)
comment 'tag和video关联表';

create table session
(
id int unsigned auto_increment
u_id int unsigned not null
primary key,
uid int unsigned not null,
session_key varchar(128) not null,
session_key varchar(64) not null,
created_at timestamp default CURRENT_TIMESTAMP not null,
updated_at timestamp default CURRENT_TIMESTAMP not null,
constraint session_session_key_uindex
unique (session_key)
);

create table user
(
id int auto_increment
id int unsigned auto_increment
primary key,
avatar varchar(64) null,
cover varchar(64) null,
nickname varchar(32) not null,
password varchar(255) not null,
status tinyint unsigned default '1' not null,
email varchar(255) not null,
gender tinyint unsigned default '0' not null,
birthday bigint not null,
followers_num bigint unsigned default '0' not null,
followings_num bigint unsigned default '0' not null,
short_desc varchar(1000) not null,
created_at bigint unsigned not null,
updated_at bigint unsigned not null,
constraint uq_email
unique (email)
);

create table video_analysis
(
id int unsigned auto_increment
primary key,
avatar varchar(64) null,
cover varchar(64) null,
nickname varchar(32) null,
password varchar(255) null,
status tinyint default 1 not null,
email varchar(128) null,
gender tinyint default 0 not null,
birthday bigint not null,
followers_num bigint unsigned default '0' not null,
followings_num bigint unsigned default '0' not null,
short_desc varchar(255) null,
created_at bigint unsigned not null,
updated_at bigint unsigned not null
type varchar(32) not null,
`key` varchar(32) not null,
score int not null,
expand varchar(1024) null,
created_at bigint unsigned not null
);

create index video_analysis_key_index
on video_analysis (`key`);


INSERT INTO video_analysis (type, `key`, score) VALUES ('tag', '莞儿', 80);
INSERT INTO video_analysis (type, `key`, score) VALUES ('tag', '莞儿睡不醒', 100);
Expand Down

0 comments on commit 650e061

Please sign in to comment.