Magento2概念与知识点整理-数据库表解析之EAV

Magento数据库表概述

Magento数据表数量很大,在我们安装的M2各版本中,共大约有近400张左右的Table。
与传统的Mysql建表方式有所不同,Magento为了达到字段方便扩展,结构灵活,在部分业务场中使用了EAV模式的表结构

数据库EAV的含义

1.EAV的理解:Entity-Attribute-Value/(实体-属性-值)

  • 实体:包括要存储的数据类型的信息(客户,产品…)
  • 属性:是实体的属性(颜色,大小,高度…)
  • 值:是给定属性的值(蓝色,红色,…)

也就是说,在我们传统的一张表,以eav的方式实现时,会被横向拆分为多张数据表。
这样做的好处是:可以方便的扩展字段,自定义字段。
如,我们可以在magento的后台,为商品扩展属性字段,并指定该属性的值采用的类型,如text,select下拉,checkbox等。

magento中使用到EAV模式的场景
用户Customer相关的表:

 customer_entitycustomer_entity_datetime       customer_entity_decimalcustomer_entity_int customer_entity_textcustomer_entity_varchar

客户地址相关表:

 customer_address_entitycustomer_address_entity_datetimecustomer_address_entity_decimalcustomer_address_entity_intcustomer_address_entity_textcustomer_address_entity_varchar

产品表:

 catalog_product_entity        catalog_product_entity_datetime  catalog_product_entity_decimalcatalog_product_entity_gallery catalog_product_entity_int catalog_product_entity_media_gallery  catalog_product_entity_media_gallery_valuecatalog_product_entity_media_gallery_value_to_entity catalog_product_entity_media_gallery_value_video catalog_product_entity_text catalog_product_entity_tier_pricecatalog_product_entity_varchar

分类表:

 catalog_category_entitycatalog_category_entity_datetimecatalog_category_entity_decimalcatalog_category_entity_intcatalog_category_entity_text

实体类型表:

eav_entity_int
eav_entity_varchar
eav_entity_text
eav_entity_decimal
eav_entity_datetime

PS: 我们在平时的开发中,需要对eav有一个大概的了解,这样在具体的业务逻辑中,才能清楚数据分布在了哪些表中。


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部