开发者

Database Design: how to avoid EAV? [duplicate]

开发者 https://www.devze.com 2023-03-03 21:39 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Database Design: to EAV or not to EAV?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Database Design: to EAV or not to EAV?

I'm modeling vehicle information. A vehicle can have 0 or more "equipment" (e.g. engine, wheels, spoiler, CD player, etc.). An equipment can have 0 or more "attributes" (e.g. an engine's "fuel type" might be "diesel").

I don't know in advance what these equipment are going to be (they will be defined by the user) much less what the attributes are going to be for these unknown equipment.

So, now the temptation is for me to use E开发者_运维问答AV. Am I heading in the wrong way? I'm worried I'll have to do something like this: find all vehicles where fuel type is diesel, etc. Sounds painful to me.

Any suggestions for alternative approach, if needed?


The rules of thumb are:

  1. If a key/value pair might be part of a where clause or manipulated through sql, it should probably be an appropriately typed column in the table rather than in an eav store.

  2. If multiple key/value pairs are frequently combined, they probably belong in a separate table.

0

精彩评论

暂无评论...
验证码 换一张
取 消