用MySQL建立一个应用商店的数据库(学习练手)
数据来源,网上公开资源
--APP信息表
CREATE TABLE `app_info`(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID, APP的Id',
`app_name` varchar(255) DEFAULT '' COMMENT '名称',
`licon_url` varchar(255) DEFAULT '' COMMENT 'icon地址',
`version` varchar(32) DEFAULT '' COMMENT '版本号',
`app_size` varchar(32) DEFAULT '' COMMENT '包大小',
`banner_info` varchar (4096) DEFAULT '' COMMENT 'banner信息',
`developer_id` varchar(255) DEFAULT '' COMMENT '开发者Id',
`summary` varchar(512) DEFAULT '' COMMENT '简介',
`app_desc` text COMMENT '详细信息',
`download_url` varchar(255) DEFAULT '' COMMENT '下载链接',
`price` int(10) DEFAULT '0' COMMENT '价格,单位:分',
`status` tinyint(4) unsigned DEFAULT '0' COMMENT '状态, 1:待审核, 2:审核通过, 3, 已下线',
`version_desc` varchar(4096) DEFAULT '' COMMENT '',
--`create_time` datetime DEFAULT '0000-00-00 00:00:00',
--`update_time` datetime DEFAULT '0000-00-00 00:00:00',
`create_time` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(10) NOT NULL DEFAULT 0 COMMENT '更新',
PRIMARY KEY (`id`),
KEY `idx_app_name` (`app_name`),
KEY `idx_developer` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=100000 DEFAULT CHARSET=utf8 COMMENT= 'app信息表' ;
--APP扩展信息表
CREATE TABLE `app_ext_info`(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`app_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'app_id',
`install_count` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'app安装量',
`score` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '评分',
`comment_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '评论量',
`create_time` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_app_id` (`app_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='app扩展信息表';
--APP分类表
CREATE TABLE `app_category`(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`parent_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '父分类id',
`name` varchar(64) NOT NULL DEFAULT '' COMMENT '分类名称',
`icon` varchar(512) NOT NULL DEFAULT '' COMMENT 'icon地址',
`category_desc` text COMMENT '分类描述',
`category_level` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '分类级别',
`status` tinyint (4) unsigned NOT NULL DEFAULT '0' COMMENT '当前状态, 1:使用中,隐藏',
`display_order` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序,值越大越靠前',
`create_time` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(10) NOT NULL DEFAULT 0 COMMENT '更新',
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分类信息表';
--APP分类关系表
CREATE TABLE `app_category_rel`(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`app_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'app_id',
`category_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '最低层分类ID',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_category_app` (`category_id`,`app_record_id`),
KEY `idx_app` (`app_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='app和分类关联表';
--APP评论表
CREATE TABLE `app_comment`(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`app_id` bigint (20) NOT NULL DEFAULT '0' COMMENT 'app_id',
`title` varchar(255) DEFAULT '' COMMENT '评论标题',
`content` varchar(2048) DEFAULT '' COMMENT '评论内容',
`parent_id` bigint(20) DEFAULT '0' COMMENT '父评论Id',
`commenter_uid` bigint(20) DEFAULT '0' COMMENT '评论用户Id',
--`commenter_name` varchar(255) DEFAULT '' COMMENT '评论用户名称',
--`commenter_avatar` varchar(255) DEFAULT '' COMMENT '品够你用户头像',
`top_flag` tinyint(4) DEFAULT '0' COMMENT '是否置顶',
`like_count` int(10) DEFAULT '0' COMMENT '评论的赞数量',
`status` tinyint (4) DEFAULT '0' COMMENT '评论状态',
`create_time` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(10) NOT NULL DEFAULT 0 COMMENT '更新l',
PRIMARY KEY (`id`),
KEY `idx_app_status` (`app_id`,`status`,`top_flag`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='评论信息表';
--用户安装信息表
CREATE TABLE `user_app_relation`(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`user_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '用户Id',
`app_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'app_id',
`create_time` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
`is_del` tinyint(4) NOT NULL DEFAULT '0' COMMENT '1:删除 0:未删除',
PRIMARY KEY (`id`),
KEY `idx_user_app` (`user_id`,`app_id`)
)ENGINE=InnoDB AUTO_INCREMENT=8063 DEFAULT CHARSET=utf8 COMMENT='技能购买关系表';
--APP评分 `` '' ()
CREATE TABLE `bot_score`(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`app_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'app_id',
`score` int(10) DEFAULT '0' COMMENT '用户评分',
`commenter_uid` bigint(20) DEFAULT '0' COMMENT '评分用户Id',
`status` tinyint(4) DEFAULT '0' COMMENT '评分状态',
`create_time` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_uid_score` (`app_id`,`commenter_uid`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='APP评分表';