SPU和SKU概念 SPU = Standard Product Unit (标准化产品单元) SPU是商品信息聚合的最小单位,是一组可复用、易检索的标准化信息的集合,该集合描述了一个产品 的特性。通俗点讲,属性值、特性相同的商品就可以称为一个SPU。
SKU=stock keeping unit(库存量单位) SKU即库存进出计量的单位, 可以是以件、盒、托盘等为单位。 SKU是物理上不可分割的最小存货单元。在使用时要根据不同业态,不同管理模式来处理。在服装、鞋 类商品中使用最多最普遍。 ?
数据库结构图
?
?数据库结构 mysql8
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for attr_value
-- ----------------------------
DROP TABLE IF EXISTS `attr_value`;
CREATE TABLE `attr_value` (
`attr_value_id` bigint(0) NOT NULL,
`attr_id` bigint(0) NULL DEFAULT NULL,
`value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
PRIMARY KEY (`attr_value_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '属性值' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for attribute
-- ----------------------------
DROP TABLE IF EXISTS `attribute`;
CREATE TABLE `attribute` (
`attr_id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '名称',
`status` int(0) NULL DEFAULT 0 COMMENT '状态',
`type` int(0) NULL DEFAULT NULL COMMENT '属性类型 1 规格属性 2 销售属性',
`category_id` bigint(0) NULL DEFAULT NULL COMMENT '分类id',
PRIMARY KEY (`attr_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '属性' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for brand
-- ----------------------------
DROP TABLE IF EXISTS `brand`;
CREATE TABLE `brand` (
`brand_id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '品牌id',
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '品牌名称',
`image` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '品牌图片地址',
`initial` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '品牌的首字母',
`sort` int(0) NULL DEFAULT NULL COMMENT '排序',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`brand_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '品牌表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for category
-- ----------------------------
DROP TABLE IF EXISTS `category`;
CREATE TABLE `category` (
`id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '分类ID',
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分类名称',
`sort` int(0) NULL DEFAULT NULL COMMENT '排序',
`parent_id` bigint(0) NULL DEFAULT NULL COMMENT '上级ID',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `parent_id`(`parent_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '商品类目' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for category_attr_rel
-- ----------------------------
DROP TABLE IF EXISTS `category_attr_rel`;
CREATE TABLE `category_attr_rel` (
`category_id` bigint(0) NOT NULL COMMENT '商品分类id',
`attr_id` bigint(0) NOT NULL COMMENT '属性分类表',
PRIMARY KEY (`category_id`, `attr_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '分类属性表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for category_brand_rel
-- ----------------------------
DROP TABLE IF EXISTS `category_brand_rel`;
CREATE TABLE `category_brand_rel` (
`category_id` bigint(0) NOT NULL COMMENT '分类ID',
`brand_id` bigint(0) NOT NULL COMMENT '品牌ID',
PRIMARY KEY (`brand_id`, `category_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '分类品牌关系表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for pro_sku_attr
-- ----------------------------
DROP TABLE IF EXISTS `pro_sku_attr`;
CREATE TABLE `pro_sku_attr` (
`id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`sku_id` bigint(0) NULL DEFAULT NULL COMMENT '商品SKU_ID',
`attr_id` bigint(0) NULL DEFAULT NULL COMMENT '属性id',
`sort` int(0) NULL DEFAULT NULL COMMENT '排序',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品规格属性' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for pro_spu_attr
-- ----------------------------
DROP TABLE IF EXISTS `pro_spu_attr`;
CREATE TABLE `pro_spu_attr` (
`id` bigint(0) NOT NULL COMMENT '主键id',
`spu_id` bigint(0) NULL DEFAULT NULL COMMENT '商品SPUid',
`attr_id` bigint(0) NULL DEFAULT NULL COMMENT '属性id',
`sort` int(0) NULL DEFAULT NULL COMMENT '排序',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品属性' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for product_detail
-- ----------------------------
DROP TABLE IF EXISTS `product_detail`;
CREATE TABLE `product_detail` (
`spu_id` bigint(0) NOT NULL COMMENT '商品SPUid',
`content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '富文本介绍',
PRIMARY KEY (`spu_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品详细' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for product_sku
-- ----------------------------
DROP TABLE IF EXISTS `product_sku`;
CREATE TABLE `product_sku` (
`sku_id` bigint(0) NOT NULL COMMENT '主键id',
`spu_id` bigint(0) NULL DEFAULT NULL COMMENT '商品SPUid',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'SKU名称',
`code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品规格编号',
`intro` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格介绍',
`sales_volume` int(0) NULL DEFAULT NULL COMMENT '销量',
`price` decimal(10, 2) NULL DEFAULT NULL COMMENT '价格',
`cover` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '封面',
`status` int(0) NULL DEFAULT 0 COMMENT '商品状态 0 下架 1-正常',
`is_delete` int(0) NULL DEFAULT 0 COMMENT '是否删除,0:未删除,1:已删除',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`sku_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品规格' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for product_sku_img
-- ----------------------------
DROP TABLE IF EXISTS `product_sku_img`;
CREATE TABLE `product_sku_img` (
`id` bigint(0) NOT NULL COMMENT '主键id',
`sku_id` bigint(0) NULL DEFAULT NULL COMMENT '商品SKUid',
`image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '图片路径',
`sort` int(0) NULL DEFAULT NULL COMMENT '排序',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品规格图集合' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for product_spu
-- ----------------------------
DROP TABLE IF EXISTS `product_spu`;
CREATE TABLE `product_spu` (
`spu_id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
`category_id` bigint(0) NULL DEFAULT NULL COMMENT '商品类目id',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'SPU名',
`code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品编号',
`cover` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '封面',
`intro` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品介绍',
`brand_id` bigint(0) NULL DEFAULT NULL COMMENT '品牌ID',
`after_sales_service` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '售后服务',
`is_marketable` int(0) NULL DEFAULT 0 COMMENT '是否上架,0已下架,1已上架',
`is_delete` int(0) NULL DEFAULT 0 COMMENT '是否删除,0:未删除,1:已删除',
`status` int(0) NULL DEFAULT 0 COMMENT '审核状态,0:未审核,1:审核不通过,2:已审核',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`spu_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for product_spu_img
-- ----------------------------
DROP TABLE IF EXISTS `product_spu_img`;
CREATE TABLE `product_spu_img` (
`id` bigint(0) NOT NULL COMMENT '主键id',
`spu_id` bigint(0) NULL DEFAULT NULL COMMENT '商品SPUid',
`image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '图片路径',
`sort` int(0) NULL DEFAULT NULL COMMENT '排序',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品图片集合' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for product_stock
-- ----------------------------
DROP TABLE IF EXISTS `product_stock`;
CREATE TABLE `product_stock` (
`sku_id` bigint(0) NOT NULL COMMENT '商品SKUid',
`quantity` int(0) NULL DEFAULT 0 COMMENT '库存数量',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`sku_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品规格库存' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
|