bigdata/chapter2/init.sql

89 lines
3.2 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 初始化脚本
create table crawl_infos (
`id` int(11) NOT NULL AUTO_INCREMENT,
total_count int comment '采集总量',
today_total_count int comment '当天采集量',
product_count int comment '产品采集条数',
today_product_count int comment '当天产品采集条数',
comment_count int comment '评论采集条数',
today_comment_count int comment '当天评论采集条数',
created_at datetime DEFAULT CURRENT_TIMESTAMP comment '统计时间',
PRIMARY KEY (`id`)
) COMMENT='采集信息表';
create table platform_infos (
`id` int(11) NOT NULL AUTO_INCREMENT,
free_cpu int comment '空闲cpu',
us_cpu int comment '用户cpu使用量',
sys_cpu int comment '系统cpu使用量',
total_memory int comment '总内存',
used_memory int comment '占用内存',
freed_memory int comment '空闲内存',
process_count int comment '进程数'
uptime varchar(255) comment '启动时间'
) comment='平台信息';
create table news (
`id` int(11) NOT NULL AUTO_INCREMENT,
comment_time varchar(255) comment '评论时间',
content varchar(1024) comment '评论内容',
comment_id varchar(255) comment '评论ID',
PRIMARY KEY (`id`)
)comment='最新抓取的20条信息';
create table last_day_counts (
`id` int(11) NOT NULL AUTO_INCREMENT,
last_day int default 0,
product_c int default 0,
comment_c int default 0,
PRIMARY KEY (`id`)
)comment ='最后5天历史采集量';
insert into last_day_counts(last_day, product_c, comment_c) values(1, 0, 0);
insert into last_day_counts(last_day, product_c, comment_c) values(2, 0, 0);
insert into last_day_counts(last_day, product_c, comment_c) values(3, 0, 0);
insert into last_day_counts(last_day, product_c, comment_c) values(4, 0, 0);
insert into last_day_counts(last_day, product_c, comment_c) values(5, 0, 0);
create table top10_sells (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_n` int default 0,
`product_name` varchar(1024) comment '商品名',
`comment_c` int default 0 comment '销量',
`good_c` int default 0 comment '好评',
`price` int default 0 comment '价格',
PRIMARY KEY (`id`)
) comment = '排名前10销量产品';
insert into top10_sells(order_n, product_name, comment_c, good_c) values(1, '', 0, 0);
insert into top10_sells(order_n, product_name, comment_c, good_c) values(2, '', 0, 0);
insert into top10_sells(order_n, product_name, comment_c, good_c) values(3, '', 0, 0);
insert into top10_sells(order_n, product_name, comment_c, good_c) values(4, '', 0, 0);
insert into top10_sells(order_n, product_name, comment_c, good_c) values(5, '', 0, 0);
insert into top10_sells(order_n, product_name, comment_c, good_c) values(6, '', 0, 0);
insert into top10_sells(order_n, product_name, comment_c, good_c) values(7, '', 0, 0);
insert into top10_sells(order_n, product_name, comment_c, good_c) values(8, '', 0, 0);
insert into top10_sells(order_n, product_name, comment_c, good_c) values(9, '', 0, 0);
insert into top10_sells(order_n, product_name, comment_c, good_c) values(10, '', 0, 0);
create table datas (
`id` int(11) NOT NULL AUTO_INCREMENT,
`key` varchar(255),
`data` json,
PRIMARY KEY (`id`)
) comment = '通用配置表';
insert into datas (`key`, data) values ('from_type', '{}');