“EAV”或“Class / Concrete Table Inheritance”数据库的设计 [英] Design of an 'EAV' or 'Class/Concrete Table Inheritance' database for stock control
问题描述
我的问题是是否要去 Class / Concrete Table Inheritance 或者基于EAV的模式。我不知道什么属性项将具有,所以推测一个Class / Concrete Table Inheritance方法将需要最终用户添加新的表到数据库(这可能吗?)。
请参阅我建议的 EAV模式。这会是一个合理的解决方案吗?我认为我正确的说要识别一个库存项目,有必要在EV表格的查询中执行多个自联接。
注意使用PHP,MySQL和Zend Framework开发
-
更改很少,之间,继续表继承,但是模式的更改应该由您自己或DBA完成。
-
如果属性更改是常见的,而您仅限于关系数据库,请使用 EAV 。
I am developing a stock control system for a construction project. The storeman is responsible for adding new stock and distributing/returning it to/from employees. The items (and hence their attributes) will be very varied; e.g. steelwork, clothing, plant/machinery, tools, etc.
My question is whether to go for a Class/Concrete Table Inheritance or EAV based schema. I don't know what attributes items will have, so presumably a Class/Concrete Table Inheritance approach would require the end user to add new tables to the database (is this possible?).
Please see my proposed EAV schema. Would this be a reasonable solution? I think I'm right in saying that to identify an item of stock, it would be necessary to perform multiple self joins in a query on the 'EV' table?
N.B. Developing using PHP, MySQL and Zend Framework.
If attribute changes are few and far between, go for Table Inheritance, but the changes to the schema should be done by yourself or a DBA. Programmatically modifying your schema based on user input seems like a bad idea.
If attribute changes are fairly common, consider using a document-oriented database like MongoDB or CouchDB.
If attribute changes are common and you are restricted to relational databases, go with EAV.
这篇关于“EAV”或“Class / Concrete Table Inheritance”数据库的设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!