当前位置 博文首页 > X.Jan:【数据仓库】|5 维度建模设计和实施过程
人们普遍认为,在数据仓库和商业智能中,维度模型事给用户显示信息的首选结构,它更易于理解和使用。又因为大数据和Hadoop的出现,允许了数据的高冗余,维度建模便越发多公司使用。
数据域是指面向业务分析,将业务过程或者维度进行抽象的集合。业务过程可以概括为个个不可拆分的行为事件,如下单、支付、退款。为保障整个体系的生命力,数据域需要抽象提炼,并且长期维护和更新,但不轻易变动。在划分数据域时,既能涵盖当前所有的业务需求,又能在新业务进入时无影响地被包含进已有的数据域中或者扩展新的数据域。 ------ 《阿里巴巴大数据之路》
数据域
|
业务过程
|
买家域和卖家域
|
注册、登录、装修、开店、关店等
|
商品域
|
发布、上架、下架、重发、SKU库存管理等
|
交易域
|
加购、下单、支付、确认收货、退款等
|
事件域
|
曝光、浏览、点击、滑动等
|
营销活动域
|
限时购、秒杀、满减、团购、砍价助力等
|
互动域
|
评论、发帖、回帖等
|
仓储配送域
|
商品采购、发货、入库、物流信息跟踪等
|
财务域
|
买家账户、卖家账户、平台账户、推广账户等
|
售后域
|
退款退货、申诉、投诉、纠纷等
|
直播域
|
直播间开通、注销、点赞、弹幕、打赏、关注等
|
域英文缩写:buyer/saller
|
公共维度
|
||||||||
数据域
|
业务过程
|
日期
|
买家
|
卖家
|
店铺
|
商品
|
订单
|
活动
|
地区
|
买家域和卖家域
|
注册
|
√
|
√
|
√
|
×
|
×
|
×
|
×
|
×
|
买家域和卖家域
|
登录
|
√
|
√
|
√
|
×
|
×
|
×
|
×
|
×
|
买家域和卖家域
|
装修
|
√
|
×
|
√
|
√
|
×
|
×
|
×
|
×
|
买家域和卖家域
|
开店
|
√
|
×
|
√
|
√
|
×
|
×
|
×
|
×
|
买家域和卖家域
|
关店
|
√
|
×
|
√
|
√
|
×
|
×
|
×
|
×
|
买家域和卖家域
|
收藏
|
√
|
√
|
√
|
√
|
×
|
×
|
×
|
×
|
求所有商品最近三十天的浏览人数和交易金额
drop table dim.dim_item; /*==============================================================*/ /* Table: 商品维度表 */ /*==============================================================*/ create table dim.dim_item ( item_id bigint comment '商品ID', item_name string comment '商品名称', img_url string comment '商品图片链接', properties Map<string,string> comment '商品属性(颜色、尺寸、尺码)', status bigint comment '商品状态', price bigint comment '商品价格', class_id_1 bigint comment '一级类目ID', class_id_1_name string comment '一级类目名称', class_id_2 bigint comment '二级类目ID', class_id_2_name string comment '二级类目名称', class_id_3 bigint comment '三级类目ID', class_id_3_name string comment '三级类目名称', brand_id bigint comment '品牌ID', brand_name string comment '品牌名称', create_tm string comment '创建时间 (yyyy-MM-dd hh:mm:ss)', chk_tm string comment '审核时间 (yyyy-MM-dd hh:mm:ss)', seller_id bigint comment '卖家ID', saller_name string comment '卖家名称', shop_id bigint comment '店铺ID', shop_name string comment '店铺名称', is_self_support bigint comment '是否店铺自营', supplier_id bigint comment '供应商ID', supplier_name string comment '供应商名称', deli_country_id bigint comment '发货国家ID', deli_country_name string comment '发货国家名称', deli_province_id bigint comment '发货省ID', deli_province_name string comment '发货省名称', deli_city_id bigint comment '发货市ID', deli_city_name string comment '发货市名称', deli_area_id bigint comment '发货区ID', deli_area_name string comment '发货区名称', dw_create_tm string comment '数仓-记录创建时间 (yyyy-MM-dd hh:mm:ss)', dw_update_tm string comment '数仓-记录更新时间 (yyyy-MM-dd hh:mm:ss)', dw_source_sys string comment '数仓-来源系统缩写', dw_source_tabs string comment '数仓-来源表列表(系统ID1.表名1,系统ID2.表名2... ...)', constraint PK_DIM_ITEM primary key (item_id) ) comment '商品维度表-全站' partitioned by (parent_id bigint comment '母商品ID');
drop table dwd.dwd_sale_order_fct; /*==============================================================*/ /* Table: 订单交易多事务事实表(下单、支付,当前事务事实需要置零处理)*/ /*==============================================================*/ create table dwd.dwd_sale_order_fct ( id bigint comment 'ID', order_id bigint comment '订单号', big_order_id bigint comment '大订单ID', sku_id bigint comment 'SKUID', sku_name string comment 'SKU名称', item_id bigint comment '商品ID', parent_id bigint comment '母商品ID', item_name string comment '商品名称', class_id_1_name string comment '商品一级类目名称', class_id_2_name string comment '商品二级类目名称', class_id_3_name string comment '商品三级类目名称', item_price bigint comment '商品价格', buyer_id bigint comment '买家ID', buyer_name string comment '买家名称', saller_id bigint comment '卖家ID', saler_name string comment '卖家名称', shop_id bigint comment '店铺ID', shop_name string comment '店铺名称', order_tm string comment '下单时间 (yyyy-MM-dd hh:mm:ss)', order_num bigint comment '下单数量', order_amt bigint comment '下单金额', share_order_amt bigint comment '下单分摊金额', discount_order_amt bigint comment '下单优惠金额', pay_tm string comment '支付时间(yyyy-MM-dd hh:mm:ss)', pay_num bigint comment '支付数量', buy_amt bigint comment '支付金额', share_buy_amt bigint comment '支付分摊金额', discount_buy_amt bigint comment '支付优惠金额', share_ship_amt bigint comment '运费分摊', rev_address_id bigint comment '收货地址行政区域', ship_address_door_num string comment '收货地址门牌号', dw_create_tm string comment '数仓-记录创建时间 (yyyy-MM-dd hh:mm:ss)', dw_update_tm string comment '数仓-记录更新时间 (yyyy-MM-dd hh:mm:ss)', dw_source_sys string comment '数仓-来源系统缩写', dw_source_tabs string comment '数仓-来源表列表(系统ID1.表名1,系统ID2.表名2... ...)', constraint