本资料为2020年尚硅谷谷粒商城项目的数据库设计文档,详细记录了项目中所需的SQL建表语句,旨在帮助开发者理解和构建该电商系统的数据架构。
gulimall_pms 商品删除表语句如下:
```sql
drop table if exists pms_attr;
drop table if exists pms_attr_attrgroup_relation;
drop table if exists pms_attr_group;
drop table if exists pms_brand;
drop table if exists pms_category;
drop table if exists pms_category_brand_relation;
drop table if exists pms_comment_replay;
drop table if exists pms_product_attr_value;
drop table if exists pms_sku_images;
drop table if exists pms_sku_info;
drop table if exists pms_sku_sale_attr_value;
drop table if exists pms_spu_comment;
drop table if exists pms_spu_images;
drop table if exists pms_spu_info;
drop table if exists pms_spu_info_desc;
```
创建表 `pms_attr`:
```sql
create table pms_attr(
attr_id bigint not null auto_increment comment 属性id,
attr_name char(30) comment 属性名,
search_type tinyint comment 是否需要检索[0-不需要,1-需要],
icon varchar(255) comment 属性图标,
value_select char(255) comment 可选值列表[用逗号分隔],
attr_type tinyint comment 属性类型[0-销售属性,1-基本属性,2-既是销售属性又是基本属性],
enable bigint comment 启用状态[0 - 禁用,1 - 启用],
catelog_id bigint comment 所属分类,
show_desc tinyint comment 快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整,
primary key (attr_id)
);
alter table pms_attr comment 商品属性;
```
创建表 `pms_attr_attrgroup_relation`:
```sql
create table pms_attr_attrgroup_relation(
id bigint not null auto_increment comment id,
attr_id bigint comment 属性id,
attr_group_id bigint comment 属性分组id,
attr_sort int comment 属性组内排序,
primary key (id)
);
alter table pms_attr_attrgroup_relation comment 属性&属性分组关联;
```
创建表 `pms_attr_group`:
```sql
create table pms_attr_group(
attr_group_id bigint not null auto_increment comment 分组id,
attr_group_name char(20) comment 组名,
sort int comment 排序,
descript varchar(255) comment 描述,
icon varchar(255) comment 组图标,
catelog_id bigint comment 所属分类id,
primary key (attr_group_id)
);
alter table pms_attr_group comment 属性分组;
```
创建表 `pms_brand`:
```sql
create table pms_brand(
brand_id bigint not null auto_increment comment 品牌id,
name char(50) comment 品牌名,
logo varchar(2000) comment 品牌logo地址,
descript longtext comment 介绍,
show_status tinyint comment 显示状态[0-不显示;1-显示],
first_letter char(1) comment 检索首字母,
sort int comment 排序,
primary key (brand_id)
);
alter table pms_brand comment 品牌;
```
创建表 `pms_category`:
```sql
create table pms_category(
cat_id bigint not null auto_increment comment 分类id,
name char(50) comment 分类名称,
parent_cid bigint comment 父分类id,
cat_level int comment 层级,
show_status tinyint comment 是否显示[0-不显示,1显示],
sort int comment 排序,
icon char(255) comment 图标地址,
product_unit char(50) comment 计量单位,
product_count int comment 商品数量,
primary key (cat_id)
);
alter table pms_category comment 商品三级分类;
```
创建表 `pms_category_brand_relation`:
```sql
create table pms_category_brand_relation(
id bigint not null auto_increment,
brand_id bigint comment 品牌id,
catelog_id bigint comment 分类id,
brand_name varchar(255),
catelog_name varchar(255),
primary key (id)
);
alter table pms_category_brand_relation comment 品牌分类关联;
```
创建表 `pms_comment_replay`:
```sql
create table pms_comment_replay(
id bigint not null auto_increment comment id,
comment_id bigint comment 评论id,
reply_id bigint comment 回复id,
);
alter table pms_comment_replay comment 评价回复;
```
以上为gulimall_pms 商品