ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

创建一套电商店铺使用的数据库

2022-01-07 11:33:15  阅读:179  来源: 互联网

标签:NULL varchar decimal DEFAULT 数据库 ID int 电商 店铺


create database DBH;
– drop database H数据库;
use DBH;
CREATE TABLE 竞店列表 (
店铺ID varchar(20) primary key,
店铺名称 varchar(30) NOT NULL,
店铺性质 varchar(10) DEFAULT NULL,
店铺简称 varchar(10) NOT NULL
);
CREATE TABLE 竞品列表 (
商品ID varchar(20) PRIMARY KEY,
商品名称 varchar(30) not NULL,
型号 varchar(20) DEFAULT NULL,
店铺ID varchar(20),
商品状态 varchar(10) DEFAULT NULL,
网址链接 tinytext DEFAULT NULL,
FOREIGN KEY (店铺ID) REFERENCES 竞店列表(店铺ID)
);
CREATE TABLE sku列表 (
skuID varchar(20) PRIMARY KEY,
sku名称 varchar(50) not NULL,
品名 varchar(10),
颜色 varchar(10),
电池类型 varchar(10),
电池容量 varchar(10),
是否可提 varchar(1),
商品ID varchar(20),
店铺 char(2) not null,
FOREIGN KEY (商品ID) REFERENCES 竞品列表(商品ID)
);

CREATE TABLE 商家编码表 (
商家编码 varchar(30) PRIMARY KEY,
商品名称 varchar(50) not NULL,
电池规格 varchar(20),
颜色 varchar(20),
店铺 char(2) not null
);
CREATE TABLE 店铺总销售数据 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
统计日期 date NOT NULL,
商品ID varchar(20) ,
商品访客数 int DEFAULT “0”,
商品浏览量 int DEFAULT “0”,
平均停留时长 float DEFAULT “0.0”,
详情页跳出率 float DEFAULT “0.0”,
商品收藏人数 int DEFAULT “0”,
商品加购件数 int DEFAULT “0”,
商品加购人数 int DEFAULT “0”,
下单买家数 int DEFAULT “0”,
下单件数 int DEFAULT “0”,
下单金额 decimal(12,2) DEFAULT “0.00”,
支付买家数 int DEFAULT “0”,
支付件数 int DEFAULT “0”,
支付金额 decimal(12,2) DEFAULT “0.00”,
支付新买家数 int DEFAULT “0”,
支付老买家数 int DEFAULT “0”,
老买家支付金额 decimal(12,2) DEFAULT “0.00”,
聚划算支付金额 decimal(12,2) DEFAULT “0.00”,
售中售后成功退款金额 decimal(12,2) DEFAULT “0.00”,
搜索引导访客数 int DEFAULT “0”,
搜索引导支付买家数 int DEFAULT “0”,
unique(统计日期,商品ID),
FOREIGN KEY (商品ID) REFERENCES 竞品列表 (商品ID)
) ;

– truncate sku列表;
create table sku销售数据(
序列ID int primary key auto_increment,
店铺 char(2) not null,
日期 date NOT NULL,
skuID varchar(20) not null,
支付金额 decimal(12,2),
支付买家数 int,
支付件数 int,
下单件数 int,
下单金额 decimal(12,2),
下单买家数 int,
加购件数 int,
unique(日期,skuID),
foreign key(skuID) references sku列表(skuID)
);
create table 单品销售(
序列ID int primary key auto_increment,
店铺 char(2) not null,
日期 date NOT NULL,
商品ID varchar(20) not null,
商家编码 varchar(30) not null,
销售额 decimal(12,2),
销售量 int,
退款额 decimal(12,2),
退货量 int,
unique(日期,商品ID,商家编码),
foreign key(商品ID) references 竞品列表(商品ID),
foreign key(商家编码) references 商家编码表(商家编码)
);
CREATE TABLE 竞品关键指标 (
序列ID int primary key auto_increment,
商品ID varchar(20) ,
日期 date NOT NULL,
交易金额 decimal(12,2) DEFAULT ‘0.00’,
访客人数 int DEFAULT ‘0’,
搜索人数 int DEFAULT ‘0’,
收藏人数 int DEFAULT ‘0’,
加购人数 int DEFAULT ‘0’,
支付人数 int DEFAULT ‘0’,
支付件数 int DEFAULT ‘0’,
FOREIGN KEY (商品ID) REFERENCES 竞品列表 (商品ID) ,
unique(商品ID,日期)
) ;
CREATE TABLE 竞店关键指标 (
序列ID int primary key auto_increment,
店铺名 varchar(30) NOT NULL,
店铺ID varchar(20) ,
日期 date NOT NULL,
交易金额 decimal(12,2) DEFAULT ‘0.00’,
访客人数 int DEFAULT ‘0’,
支付人数 int default ‘0’,
搜索人数 int DEFAULT ‘0’,
收藏人数 int DEFAULT ‘0’,
加购人数 int DEFAULT ‘0’,
FOREIGN KEY (店铺ID) REFERENCES 竞店列表 (店铺ID) ,
unique(店铺ID,日期)
) ;
CREATE TABLE 竞品入店来源 (
序列ID int primary key auto_increment,
商品ID varchar(20) ,
日期 date NOT NULL,
流量来源 varchar(30) not NULL,
交易金额 decimal(12,2) DEFAULT ‘0.00’,
访客人数 int DEFAULT ‘0’,
支付人数 int DEFAULT ‘0’,
FOREIGN KEY (商品ID) REFERENCES 竞品列表 (商品ID),
unique(商品ID,日期,流量来源)
) ;
CREATE TABLE 竞店入店来源 (
序列ID int primary key auto_increment,
店铺名 varchar(30) NOT NULL,
店铺ID varchar(20) ,
日期 date NOT NULL,
流量来源 varchar(30) not NULL,
交易金额 decimal(12,2) DEFAULT ‘0.00’,
访客人数 int DEFAULT ‘0’,
支付人数 int DEFAULT ‘0’,
FOREIGN KEY (店铺ID) REFERENCES 竞店列表 (店铺ID),
unique(店铺ID,日期,流量来源)
) ;
CREATE TABLE 竞品入店搜索词 (
序列ID int primary key auto_increment,
商品ID varchar(20) ,
日期 date NOT NULL,
关键词 varchar(30) not NULL,
交易金额 decimal(12,2) DEFAULT ‘0.00’,
访客人数 int DEFAULT ‘0’,
支付件数 int DEFAULT ‘0’,
FOREIGN KEY (商品ID) REFERENCES 竞品列表 (商品ID),
unique(商品ID,日期,关键词)
) ;
CREATE TABLE 超推定向 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
推广渠道 char(2) NOT NULL DEFAULT ‘超推’,
商品ID varchar(20) ,
日期 date not NULL,
计划 varchar(50) not NULL,
定向 varchar(100) not NULL,
有效展现 int DEFAULT NULL,
有效点击数 int DEFAULT NULL,
消耗 decimal(12,2) DEFAULT NULL,
预售订单量 int DEFAULT NULL,
预售金额 decimal(12,2) DEFAULT NULL,
引导进店量 int DEFAULT NULL,
引导进店人数 int DEFAULT NULL,
引导进店潜客人数 int DEFAULT NULL,
平均访问页面数 float DEFAULT NULL,
深度进店量 int DEFAULT NULL,
平均访问时长 float DEFAULT NULL,
收藏店铺数 int DEFAULT NULL,
关注店铺量 int DEFAULT NULL,
新客获取量 int DEFAULT NULL,
拉新成本 float DEFAULT NULL,
收藏宝贝数 int DEFAULT NULL,
添加购物车量 int DEFAULT NULL,
优惠券领取量 int DEFAULT NULL,
旺旺咨询量 int DEFAULT NULL,
拍下订单量 int DEFAULT NULL,
拍下订单金额 decimal(12,2) DEFAULT NULL,
成交订单量 int DEFAULT NULL,
成交订单金额 decimal(12,2) DEFAULT NULL,
FOREIGN KEY (商品ID) REFERENCES 竞品列表(商品ID),
unique(商品ID,日期,计划,定向)
) ;
CREATE TABLE 超推资源位 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
推广渠道 char(2) NOT NULL DEFAULT ‘超推’,
商品ID varchar(20) NOT NULL,
日期 date not NULL,
计划 varchar(50) not NULL,
资源位 varchar(100) not NULL,
有效展现 int DEFAULT NULL,
有效点击数 int DEFAULT NULL,
消耗 decimal(12,2) DEFAULT NULL,
预售订单量 int DEFAULT NULL,
预售金额 decimal(12,2) DEFAULT NULL,
引导进店量 int DEFAULT NULL,
引导进店人数 int DEFAULT NULL,
引导进店潜客人数 int DEFAULT NULL,
平均访问页面数 float DEFAULT NULL,
深度进店量 int DEFAULT NULL,
平均访问时长 float DEFAULT NULL,
收藏店铺数 int DEFAULT NULL,
关注店铺量 int DEFAULT NULL,
新客获取量 int DEFAULT NULL,
拉新成本 float DEFAULT NULL,
收藏宝贝数 int DEFAULT NULL,
添加购物车量 int DEFAULT NULL,
优惠券领取量 int DEFAULT NULL,
旺旺咨询量 int DEFAULT NULL,
拍下订单量 int DEFAULT NULL,
拍下订单金额 decimal(12,2) DEFAULT NULL,
成交订单量 int DEFAULT NULL,
成交订单金额 decimal(12,2) DEFAULT NULL,
FOREIGN KEY (商品ID) REFERENCES 竞品列表 (商品ID) ,
unique(商品ID,日期,计划,资源位)
);
CREATE TABLE 钻展受众 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
推广渠道 char(2) NOT NULL DEFAULT ‘钻展’,
商品ID varchar(20) ,
日期 date not NULL,
受众人群名称 varchar(100) not NULL,
计划基本信息 varchar(100) not NULL,
计划组基本信息 varchar(50) not NULL,
浅层兴趣行为流转人数 int DEFAULT NULL,
深度兴趣行为流转人数 int DEFAULT NULL,
购买行为流转人数 int DEFAULT NULL,
展现 int DEFAULT NULL,
点击 int DEFAULT NULL,
消耗 decimal(12,2) DEFAULT NULL,
展现人数 int DEFAULT NULL,
深度进店量 int DEFAULT NULL,
访客时长 float DEFAULT NULL,
访客页面数 float DEFAULT NULL,
收藏宝贝量 int DEFAULT NULL,
收藏店铺量 int DEFAULT NULL,
添加购物车量 int DEFAULT NULL,
拍下订单量 int DEFAULT NULL,
拍下订单金额 decimal(12,2) DEFAULT NULL,
成交订单量 int DEFAULT NULL,
成交订单金额 decimal(12,2) DEFAULT NULL,
回访量 int DEFAULT NULL,
回搜量 int DEFAULT NULL,
预售订单量 int DEFAULT NULL,
预售订单金额 decimal(12,2) DEFAULT NULL,
FOREIGN KEY (商品ID) REFERENCES 竞品列表 (商品ID),
unique(商品ID,日期,受众人群名称,计划基本信息,计划组基本信息)
) ;
CREATE TABLE 钻展资源位 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
推广渠道 char(2) NOT NULL DEFAULT ‘钻展’,
商品ID varchar(20) ,
日期 date not NULL,
计划基本信息 varchar(100)not NULL,
计划组基本信息 varchar(50) not NULL,
广告位名称 varchar(100) not NULL,
浅层兴趣行为流转人数 int DEFAULT NULL,
深度兴趣行为流转人数 int DEFAULT NULL,
购买行为流转人数 int DEFAULT NULL,
展现 int DEFAULT NULL,
点击 int DEFAULT NULL,
消耗 decimal(12,2) DEFAULT NULL,
展现人数 int DEFAULT NULL,
深度进店量 int DEFAULT NULL,
访客时长 float DEFAULT NULL,
访客页面数 float DEFAULT NULL,
收藏宝贝量 int DEFAULT NULL,
收藏店铺量 int DEFAULT NULL,
添加购物车量 int DEFAULT NULL,
拍下订单量 int DEFAULT NULL,
拍下订单金额 decimal(12,2) DEFAULT NULL,
成交订单量 int DEFAULT NULL,
成交订单金额 decimal(12,2) DEFAULT NULL,
回访量 int DEFAULT NULL,
回搜量 int DEFAULT NULL,
预售订单量 int DEFAULT NULL,
预售订单金额 decimal(12,2) DEFAULT NULL,
FOREIGN KEY (商品ID) REFERENCES 竞品列表 (商品ID),
unique(商品ID,日期,计划基本信息,计划组基本信息,广告位名称)
);
CREATE TABLE 直通车单元 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
推广渠道 char(3) NOT NULL DEFAULT ‘直通车’,
日期 date NOT NULL,
计划id varchar(20) not NULL,
计划名称 varchar(50) not NULL,
推广类型 varchar(20) not NULL,
单元id varchar(20) not NULL,
商品id varchar(20) ,
展现量 int DEFAULT NULL,
点击量 int DEFAULT NULL,
花费 decimal(12,2) DEFAULT NULL,
直接成交金额 decimal(12,2) DEFAULT NULL,
直接成交笔数 int DEFAULT NULL,
总成交金额 decimal(12,2) DEFAULT NULL,
总成交笔数 int DEFAULT NULL,
宝贝收藏数 int DEFAULT NULL,
店铺收藏数 int DEFAULT NULL,
总收藏数 int DEFAULT NULL,
直接购物车数 int DEFAULT NULL,
总购物车数 int DEFAULT NULL,
FOREIGN KEY (商品id) REFERENCES 竞品列表 (商品ID),
unique(店铺,日期,单元id)
) ;
– drop table 直通车关键词;
CREATE TABLE 直通车关键词 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
推广渠道 char(3) NOT NULL DEFAULT ‘直通车’,
日期 date DEFAULT NULL,
计划id varchar(20) not NULL,
计划名称 varchar(30) DEFAULT NULL,
单元id varchar(20) not NULL,
关键词 varchar(50) not NULL,
商品id varchar(20) ,
展现量 int DEFAULT NULL,
点击量 int DEFAULT NULL,
花费 decimal(12,2) DEFAULT NULL,
平均展现排名 int DEFAULT NULL,
直接成交金额 decimal(12,2) DEFAULT NULL,
直接成交笔数 int DEFAULT NULL,
总成交金额 decimal(12,2) DEFAULT NULL,
总成交笔数 int DEFAULT NULL,
宝贝收藏数 int DEFAULT NULL,
店铺收藏数 int DEFAULT NULL,
直接购物车数 int DEFAULT NULL,
总购物车数 int DEFAULT NULL,
FOREIGN KEY (商品id) REFERENCES 竞品列表 (商品ID),
unique(店铺,日期,单元id,关键词)
) ;
CREATE TABLE 拉新快数据 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
推广渠道 char(3) NOT NULL DEFAULT ‘拉新快’,
日期 date not NULL,
宝贝Id varchar(20) not NULL,
计划Id varchar(20) not NULL,
计划名称 varchar(30) DEFAULT NULL,
投放周期 varchar(30) DEFAULT NULL,
套餐金额 decimal(12,2) DEFAULT NULL,
消耗 decimal(12,2) DEFAULT NULL,
曝光量 int DEFAULT NULL,
点击量 int DEFAULT NULL,
加购量 int DEFAULT NULL,
收藏量 int DEFAULT NULL,
预售成交笔数 int DEFAULT NULL,
预售成交金额 decimal(12,2) DEFAULT NULL,
成交笔数 int DEFAULT NULL,
成交金额 decimal(12,2) DEFAULT NULL,
派样量 int DEFAULT NULL,
派样金额 decimal(12,2) DEFAULT NULL,
FOREIGN KEY (宝贝Id) REFERENCES 竞品列表 (商品ID),
unique(店铺,日期,计划Id)
) ;
CREATE TABLE 明星店铺明细 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
推广渠道 char(4) NOT NULL DEFAULT ‘明星店铺’,
商品ID varchar(20) ,
日期 date NOT NULL,
计划名称 varchar(30) not NULL,
单元名称 varchar(30) not NULL,
创意名称 varchar(30) not NULL,
展现量 int DEFAULT NULL,
自然流量增量曝光 int DEFAULT NULL,
消耗 decimal(12,2) DEFAULT NULL,
触达访客数 int DEFAULT NULL,
点击量 int DEFAULT NULL,
跳转点击量 int DEFAULT NULL,
点击访客数 int DEFAULT NULL,
进店访客数 int DEFAULT NULL,
店铺收藏数 int DEFAULT NULL,
宝贝收藏数 int DEFAULT NULL,
宝贝加购数 int DEFAULT NULL,
行动访客数 int DEFAULT NULL,
店铺收藏访客数 int DEFAULT NULL,
宝贝收藏访客数 int DEFAULT NULL,
宝贝加购访客数 int DEFAULT NULL,
成交笔数 int DEFAULT NULL,
成交金额 decimal(12,2) DEFAULT NULL,
预售成交笔数 int DEFAULT NULL,
预售成交金额 float DEFAULT NULL,
成交访客数 int DEFAULT NULL,
FOREIGN KEY (商品ID) REFERENCES 竞品列表 (商品ID),
unique(店铺,日期,创意名称)
) ;
– drop table 目标与预算;
– truncate TABLE 目标与预算;
CREATE TABLE 目标与预算 (
序列ID int primary key auto_increment,
店铺 char(2) not null,
商品ID varchar(20) NOT NULL,
日期 date NOT NULL,
目标销量 int DEFAULT ‘0’,
目标销售额 decimal(12,2) DEFAULT ‘0.00’,
品销宝 decimal(12,2) DEFAULT ‘0.00’,
直通车 decimal(12,2) DEFAULT ‘0.00’,
钻展 decimal(12,2) DEFAULT ‘0.00’,
超推 decimal(12,2) DEFAULT ‘0.00’,
其他 decimal(12,2) DEFAULT ‘0.00’,
前台折让 decimal(12,2) DEFAULT ‘0.00’,
后台折让 decimal(12,2) DEFAULT ‘0.00’,
赠品 decimal(12,2) DEFAULT ‘0.00’,
FOREIGN KEY (商品ID) REFERENCES 竞品列表 (商品ID),
unique(商品ID,日期)
) ;

标签:NULL,varchar,decimal,DEFAULT,数据库,ID,int,电商,店铺
来源: https://blog.csdn.net/weixin_50810323/article/details/122360770

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有