EAV - 在电子商务案例中,真的是一个反模式吗? [英] EAV - in an ecommerce case, is it really an anti-pattern?

查看:360
本文介绍了EAV - 在电子商务案例中,真的是一个反模式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个需要可扩展数据模型的新系统。这是非常复杂的,但系统的这个结构部分对于电子商务系统的产品部分来说非常重要,所以我会用到这一点。



想象一下公司。每个公司都有一系列产品,它们具有一些基本属性,例如 name sku 描述价格等。除了这些基本属性,公司应该能够创建 n 属于公司的定制产品属性(即 Foo Corp。不应该能够看到Acme Inc.的自定义属性)。除此之外,每个公司都应该能够为每个产品翻译这些属性;所以每个自定义属性值基本上由属性产品语言



我明白EAV结构是一个反模式,如果您存储固定数量的属性,而需要扩展属性量的那个不是系统的所有者。



所以我的问题是 - 你会如何实现?在这种情况下,EAV结构真的是一种反模式吗? Magento是使用这种设计的人的一个典型例子,它似乎像是构建了一个怪物,并且必须通过实现平面索引表来修复它。但是有没有其他数据库设计模式允许这么多的灵活性?

解决方案

了解为什么EAV经常很有用被认为是一种反模式,而且这些批评对你的个案有多好。了解为什么这么多人被吸引到EAV以及他们看到的积极好处也很有用。



大多数EAV数据库的最大问题是几乎不可能写任何一种系统和综合的提取或报告系统,以便将数据转化为有用的信息。



在精心设计的关系数据库中给出良好管理的数据时,可在不到一小时的工作中开发的相同类型的报告可能需要数周才能在EAV数据库中开发。原因是数据基本上是未分析的数据,而不考虑其固有的逻辑结构。



事实证明,与某些原因其他人如此吸引EAV。您可以完全绕过数据分析。逻辑数据库设计实际上是自动的,因为所有的EAV数据库都具有相同的表格结构。当你建立一个,你已经构建了它们。



这给你一个处理一些事情,在任何情况下,你可能会考虑。数据库的逻辑结构是否真的是动态和不可知的?或者人们刚刚得出这个结论,因为时间表没有时间进行数据分析和数据库设计?



如何使用数据?人们期望做一种通常在数据库中预期数据的检索类型?还是他们计划把每一次尝试的检索作为对未知领域的探索?



在你的具体情况下,我会问一下这个重要的要求将产品数据合并在一起,即使每个公司都拥有自己的产品和属性知识库?如果这真的永远不会发生,也许你会没事的。如果没有,最好先进行管理,实现使用这些数据的难度。


I'm in the process of building a new system which will require an extendable data model. It's quite complex, but the part of the system which requires this structure is very relatable to the product part of an ecommerce system, so I'll use that as a case.

Imagine a set of companies. Each company has a range of products, which has some basic attributes such as name, sku, description, price etc. Alongside these basic attributes, the company should be able to create n custom product attributes, which belongs to the company (i.e. Foo Corp. shouldn't be able to see Acme Inc.'s custom attributes). Beside that, each company should be able to translate these attributes for each product; so each custom attribute value is basically constructed from an attribute, a product, language and a value.

I do understand that the EAV structure is an anti-pattern if you store an fixed amount of attributes and the one in need of extending the amount of attributes isn't the owner of the system.

So my question is - how would you achieve this? It the EAV structure really an anti pattern in this case? Magento is a classic example of someone using this design, and it kinda seems like they built a monster and had to 'fix' it by implementing flat index tables. But are there any other database design pattern that allows for this amount of flexibility?

解决方案

It's useful to understand why EAV is so often considered an anti-pattern, and how well those criticisms apply to your case. It's also useful to understand why so many people are drawn to EAV, and what positive benefits they see in it.

The biggest problem with most EAV databases is that it is nearly impossible to write any kind of systematic and integrated extraction or reporting system, in order to turn the data into useful information.

The same sort of report that can be developed in less than an hour's work when given well managed data in a well designed relational database can take weeks to develop in an EAV database. The reason is that the data is fundamentally unanalyzed data that has been stored without regard for its inherent logical structure.

This turns out to be very closely related to the reason why some other people are so drawn to EAV. You can bypass data analysis completely. And logical database design is practically automatic, since all EAV databases have the same table structure. When you've built one, you've built them all.

This gives you a handle on a few things to look for in any case you might consider. Is the logical structure of the database truly dynamic and unknowable? Or are people just jumping to that conclusion, because the schedule allows no time for data analysis and database design?

How will the data be used? Are people expecting to do the kind of retrieval that is classically expected of data in a database? Or are they planning on treating each attempted retrieval as an exploration into uncharted territory?

In your particular case, I would ask how long it's going to be before somebody "important" asks for product data to be combined across companies, even though each of them maintains its own knowledge base of products and attributes? If that's really never going to happen, maybe you will be ok. If not, you'd better move on before management realizes how hard it is to use this data.

这篇关于EAV - 在电子商务案例中,真的是一个反模式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆