这是使用EAV的好案例还是没有 [英] Is this a good case to use EAV or no

查看:100
本文介绍了这是使用EAV的好案例还是没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有具有不同属性的不同产品类型。由于属性太不同,因此无法将它们存储在单个表中。我目前正在查看几个选项:EAV和每种类型的表格。

I have different product types that have different attributes. They cannot be stored in a single table as the attributes are too distinct. There's a couple of options I'm currently looking at: EAV and a table for each type.

我的情况是,目前只有几种类型(假设8),但在不久的将来,几乎可以肯定100%会增长。但是增长是由我控制的,它不是由用户定义的。

My situation is, at the moment, there are only a number of types (lets say 8) but in the near future with almost 100% certainty, this can grow. But the growth is controlled by me, its not defined by users. It will be up to me to grow the product type.

我目前倾向于使用EAV(因为我可以轻松满足增长需求-我认为)但是我不确定我是否关注性能以及是否以我选择的语言(C#)对它们进行建模。我的问题是,考虑到上述情况,我是否应该为每种产品类型创建一个表并根据需要添加表,还是使用EAV是一个好案例(或者说还不错,可以接受)? / p>

I'm currently inclined to use EAV (for the reason that I can cover the growth easily - I think) but I am not sure as I'm concerned with the performance as well as modeling them in my language of choice (C#). My question is, given the scenario above, is it better for me to create a single table for each product type and add as necessary, or would this be a good case (or not even good, lets say acceptable) to use EAV?

推荐答案

对此问题没有简短的好或坏答案,因为它取决于很多事情。

There's no short good or bad answer to this concern, because it depends of many things.


  • 您有很多产品类型吗?

  • 您如何看待它们中的每一个都会发展(想想什么时候会发生什么?您将在产品中添加新字段)?

  • 是否需要处理产品的变体?

  • 您打算添加全新的字段吗?产品类型?

  • Do you have a lot of product types ?
  • How do you think each of them will evolve (think to what will happen when you will add new fields to products) ?
  • Do you need to handle "variants" of the products ?
  • Do you intend to add entirely new types of products ?

等等。如果对某些或所有这些问题的回答为是,则
EAV可能是一种不错的选择。

Etc. EAV is probably a good way to go if you answer if you answer "yes" to some or all these questions.

关于C#,我过去已经用它实现了一个EAV数据目录,并在SQL Server(即RDBMS)上使用了Entity Framework。
对我来说很好。

Regarding C#, I have implemented in the past an EAV data catalog with it, and using Entity Framework over SQL Server (so a RDBMS). It worked nice to me.

但是如果您需要处理很多产品,性能很快就会成为问题。您还可以考虑使用 NoSQL解决方案吗?

But if you need to handle a lot of products, performance can quickly become an issue. You could also look for a "NoSQL" solution, did you think about it ?

请记住,模型对象不必与数据模型匹配。
例如,如果需要,您可以为每种产品完美地设置一个stronly类型的对象。

Just keep in mind that your model object does not have to match your data model. For example you could perfectly have a stronly typed object for each type of product if you need so.

这篇关于这是使用EAV的好案例还是没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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