1、项目概述

需求

对电商业务中的用户、商品、订单的数据进行分析,观察运营的情况

架构

业务数据库:Mysql:存储最原始的数据

ETL:Kettle

数据仓库:Mysql:存储需要进行分析处理的数据

分析处理:SQL/Kettle

可视化:Superset


2、准备工作

系统

linux系统

软件

VMware虚拟机——安装linux操作系统

1 Windows版下载地址:
2 https://www.vmware.com/

finalshell——远程操作系统

 Windows版下载地址:
http://www.hostbuf.com/downloads/finalshell_install.exe
Mac版,Linux版安装及教程:
http://www.hostbuf.com/t/1059.html

mysql——数据库(安装版和压缩包版)


1 Windows版下载地址:
2 https://www.mysql.com//downloads/

datagrip——数据库管理工具

链接:https://pan.baidu.com/s/1K1pPIX9uZiAKOAiFgHMlnw
提取码:lhr4

Navicat——数据库管理工具

链接:https://pan.baidu.com/s/1eaW3CMhen_7X5sjVgs7enw
提取码:fqov

kettle——如有安装问题请自行度娘

1、Kettle的下载与安装(本文使用kettle版本为pdi-ce-7.1.0.0-12)点击下载地址官方网站

可视化工具

superset——有问题请度娘

linux环境安装依赖
yum upgrade python-setuptools
yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel
安装superset
supersetcd /root/anaconda3/
pip install email_validator -i https://pypi.douban.com/simple
pip install superset==0.30.0 -i https://pypi.douban.com/simple

3、数据环境

1、导入业务数据

将这段sql代码下载运行,生成数据库,表格

链接:https://pan.baidu.com/s/1uVYISah6hYkBqiyhIk407w
提取码:sfdm

2、构建数据仓库

通过kettle将业务数据抽取到数据分析的数据库中

链接:https://pan.baidu.com/s/1shH0zexh3WraQnMt17n-SA
提取码:ao7n

生成表格——kettle操作略

mysql> use itcast_shop_bi;

Database changed
mysql> show tables;
+--------------------------+
| Tables_in_itcast_shop_bi |
+--------------------------+
| ods_itcast_good_cats |商品分类表
| ods_itcast_goods |商品表
| ods_itcast_order_goods |订单及详情表
| ods_itcast_orders |订单表
| ods_itcast_users |用户表
| ods_itcast_area      |行政区域表
+--------------------------+

3、自动化构建抽取实现

1、地区表以及商品分类表的自动抽取

2、商品表、订单表、订单详情表、用户表

3、设置定时自动运行

4、数据分析

需求1

需求:统计 2019-09-05 订单支付的总金额、订单的总笔数

演变:统计每天的订单支付的总金额和订单的总笔数

指标:总金额、订单总笔数

维度:天

-- 创建结果表
use itcast_shop_bi;
create table app_order_total(
id int primary key auto_increment,
dt date,
total_money double,
total_cnt int
);
-- 将分析的结果保存到结果表
insert into app_order_total
select
null,
substring(createTime,1,10) as dt,-- 2019-09-05这一天的日期
round(sum(realTotalMoney),2) as total_money, -- 分组后这一天的所有订单总金额
count(orderId) as total_cnt -- 分组后这一天的订单总个数
from
ods_itcast_orders
where
substring(createTime,1,10) = '2019-09-05'
group by
substring(createTime,1,10);
-- 表结构及内容
mysql> desc app_order_user;
+----------------+------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| dt | date | YES | | NULL | |
| total_user_cnt | int | YES | | NULL | |
+----------------+------+------+-----+---------+----------------+
3 rows in set (0.00 sec) mysql> select * from app_order_user;
+----+------------+----------------+
| id | dt | total_user_cnt |
+----+------------+----------------+
| 1 | 2019-09-05 | 11 |
| 2 | 2019-09-05 | 11 |
+----+------------+----------------+
2 rows in set (0.01 sec)

需求2

需求:统计2019-09-05当天所有下单的用户总数

演变:统计订单表中2019-09-05这一天的所有订单的用户id的个数

-- 创建结果表
use itcast_shop_bi;
create table app_order_user(
id int primary key auto_increment,
dt date,
total_user_cnt int
);
-- 插入结果数据
insert into app_order_user
select
null,
substring(createTime,1,10) as dt,-- 2019-09-05这一天的日期
count(distinct userId) as total_user_cnt
from
ods_itcast_orders
where
substring(createTime,1,10) = '2019-09-05'
group by
substring(createTime,1,10);

需求3

需求;每天不同支付方式订单总额/订单笔数分析

指标:订单总额、订单总笔数

维度:时间维度【天】、支付方式维度

-- 创建结果表
create table app_order_paytype(
id int primary key auto_increment,
dt date,
pay_type varchar(20),
total_money double,
total_cnt int
);
-- 插入结果数据
insert into app_order_paytype
select
null,
substring(createTime,1,10) as dt,-- 获取每一天的日期
case payType when 1 then '支付宝' when 2 then '微信' when 3 then '现金' else '其他' end as pay_type,
round(sum(realTotalMoney),2) as total_money, -- 分组后这一天的所有订单总金额
count(orderId) as total_cnt -- 分组后这一天的订单总个数
from
ods_itcast_orders
group by
substring(createTime,1,10),payType;

需求4

需求;统计2019年9月下订单最多的用户TOP5,也就是前5名

方式一:上面考虑的是简单的情况,只获取订单个数最多的前5个人

select
date_format(dt,'%Y-%m') as dt,
userId,
userName,
count(orderId) as total_cnt
from
ods_itcast_orders
where
date_format(dt,'%Y-%m') = '2019-09'
group by
date_format(dt,'%Y-%m'),userId,userName
order by
total_cnt desc
limit 5;

方式二:我们希望得到订单个数最多的排名的前5名,如果个数相同排名相同

select
*
from (
select *,
dense_rank() over (partition by dt order by total_cnt desc) as rn
from (
select date_format(dt, '%Y-%m') as dt,
userId,
userName,
count(orderId) as total_cnt
from ods_itcast_orders
where date_format(dt, '%Y-%m') = '2019-09'
group by date_format(dt, '%Y-%m'), userId, userName
) tmp1
) tmp2 where rn < 6;

需求5

需求:统计不同分类的订单总金额以及订单总笔数【类似于统计不同支付类型的订单总金额和总笔数】

-- 创建结果表
use itcast_shop_bi;
drop table if exists app_order_goods_cat;
create table app_order_goods_cat(
id int primary key auto_increment,
dt date,
cat_name varchar(20),
total_money double,
total_num int
);
-- step2:先构建三级分类与一级分类之间的关系
-- 使用join实现
drop table if exists tmp_goods_cats;
create temporary table tmp_goods_cats as
select
t3.catId as t3Id,-- 三级分类id
t3.catName as t3Name, -- 三级分类名称
t2.catId as t2Id,
t2.catName as t2Name,
t1.catId as t1Id,
t1.catName as t1Name
from
ods_itcast_good_cats t3 join ods_itcast_good_cats t2 on t3.parentId = t2.catId
join ods_itcast_good_cats t1 on t2.parentId = t1.catId; CREATE UNIQUE INDEX idx_goods_cat3 ON tmp_goods_cats(t3Id);
CREATE UNIQUE INDEX idx_itheima_goods ON ods_itcast_goods(goodsId);
CREATE INDEX idx_itheima__order_goods ON ods_itcast_order_goods(goodsId);
-- 插入结果数据
insert into app_order_goods_cat
select
null,
substring(c.createtime,1,10) as dt,
a.t1Name,
sum(c.payPrice) as total_money,
count(distinct orderId) as total_num
from
tmp_goods_cats a left join ods_itcast_goods b on a.t3Id = b.goodsCatId
left join ods_itcast_order_goods c on b.goodsId = c.goodsId
where
substring(c.createtime,1,10) = '2019-09-05'
group by
substring(c.createtime,1,10),a.t1Name;

5、构建自动化Kettle作业实现自动化分析

创建一个作业

配置SQL脚本

定义作业的变量

6、可视化构建

订单销售总额

订单总笔数

订单总用户数

不同支付方式的总订单金额比例

不同支付方式的订单个数

不同商品分类的订单总金额

不同商品分类的订单总个数

词云图

7、构建看板


mysql-kettle-superset电商可视化数据分析的更多相关文章

  1. 大数据技术之_27_电商平台数据分析项目_02_预备知识 + Scala + Spark Core + Spark SQL + Spark Streaming + Java 对象池

    第0章 预备知识0.1 Scala0.1.1 Scala 操作符0.1.2 拉链操作0.2 Spark Core0.2.1 Spark RDD 持久化0.2.2 Spark 共享变量0.3 Spark ...

  2. [原创]如何利用BI搭建电商数据分析平台

    某电商是某大型服装集团下的重要销售平台.2015 年,该集团品牌价值达数百亿元,产品质量.市场占有率.出口创汇.销售收入连年居全国绒纺行业第一,在中国有终端店3000多家,零售额80 亿.其羊绒制品年 ...

  3. 如何利用BI搭建电商数据分析平台

    某电商是某大型服装集团下的重要销售平台.2015 年,该集团品牌价值达数百亿元,产品质量.市场占有率.出口创汇.销售收入连年居全国绒纺行业第一,在中国有终端店3000多家,零售额80 亿.其羊绒制品年 ...

  4. Amazon电商数据分析——数据获取

    最近一段时间主要重心在Amazon电商数据分析上,这是一个偏数据分析和可视化的项目.具体来说就是先获取Amazon的商品数据,数据清洗和持久化存储后作为我们自己的数据源.分析模块和可视化模块基于数据进 ...

  5. 电商打折套路分析 —— Python数据分析练习

    电商打折套路分析 ——2016天猫双十一美妆数据分析 数据简介 此次分析的数据来自于城市数据团对2016年双11天猫数据的采集和整理,原始数据为.xlsx格式 包括update_time/id/tit ...

  6. EF+MySQL乐观锁控制电商并发下单扣减库存,在高并发下的问题

    下订单减库存的方式 现在,连农村的大姐都会用手机上淘宝购物了,相信电商对大家已经非常熟悉了,如果熟悉电商开发的同学,就知道在买家下单购买商品的时候,是需要扣减库存的,当然有2种扣减库存的方式, 一种是 ...

  7. 电商网站垮IDC数据备份,MySql主从同步,图片及其它数据文件的同步

    原文网址:http://www.bzfshop.net/article/180.html 对一个电子商务网站而言,最宝贵的资源就是数据.服务器是很廉价的东西,即使烧了好几个也问题不大,但是用户数据如果 ...

  8. 电商中的库存管理实现-mysql与redis

        库存是电商系统的核心环节,如何做到不少卖,不超卖是库存关心的核心业务问题.业务量大时带来的问题是如何更快速的处理库存计算. 此处以最简模式来讨论库存设计. 以下内容只做分析,不能直接套用,欢迎 ...

  9. 常见电商项目的数据库表设计(MySQL版)

    转自:https://cloud.tencent.com/developer/article/1164332 简介: 目的: 电商常用功能模块的数据库设计 常见问题的数据库解决方案 环境: MySQL ...

随机推荐

  1. Redis入门使用 -- 个人总结

    目录 什么是Redis? Redis 与其他 key - value 数据库的对比 Redis 能干什么 Redis的安装配置 Redis启动和连接 上面开启的是非守护线程下启动(独占模式),下面我们 ...

  2. BUUOJ [CISCN2019 华北赛区 Day2 Web1]Hack World

    补一下这道题,顺便发篇博客 不知道今年国赛是什么时候,菜鸡还是来刷刷题好了 0X01 考点 SQL注入.盲注.数字型 0X02自己尝试 尝试输入1 赵师傅需要女朋友吗???随便都能有好吧 输入2 ?? ...

  3. ElasticSearch的高级复杂查询:非聚合查询和聚合查询

    一.非聚合复杂查询(这儿展示了非聚合复杂查询的常用流程) 查询条件QueryBuilder的构建方法 1.1 精确查询(必须完全匹配上,相当于SQL语句中的“=”) ① 单个匹配 termQuery ...

  4. Java 多线程 -- 协作模型:生产消费者实现方式一:管程法

    多线程通过管程法实现生产消费者模式需要借助中间容器作为换从区,还包括生产者.消费者.下面以蒸馒头为列,写一个demo. 中间容器: 为了防止数据错乱,还需要给生产和消费方法加锁 并且生产者在容器写满的 ...

  5. deepin下深度终端使用ssh-agent(xshell中的xagent功能)

    背景:从windows10换到deepin后,在连接公司的服务器遇到了问题:windows下用的是xshell,开启xagent后,可直接从公司的跳转板上连接生产服务器:在deepin的深度终端上,从 ...

  6. thinkphp5.1+ 使用 Redis 缓存

    修改 config/cache.php 将其配置成多个缓存类型,示例 <?php // +---------------------------------------------------- ...

  7. css中的宽和高

    width width表示宽 height height表示高 max-width.min-width max-width表示最大宽度 min-width表示最小宽度 max-height.min-h ...

  8. curl的$post传递多维数组

    php curl传数组的话只能传一维数组,如果想传多维数组:两个方法: 1.转换成json在传输 2. //通过curl模拟post的请求: function SendDataByCurl($url, ...

  9. java学习(第一篇)

    Java 简介 Java是由Sun Microsystems公司于1995年5月推出的Java面向对象程序设计语言和Java平台的总称.由James Gosling和同事们共同研发,并在1995年正式 ...

  10. VirtualBox 原始镜像转换成 vdi 镜像

    VBoxManage convertdd [-static] <filename> <outputfile> 将raw硬盘转换成vdi虚拟硬盘