“EAV”或“Class / Concrete Table Inheritance”数据库的设计 [英] Design of an 'EAV' or 'Class/Concrete Table Inheritance' database for stock control

查看:239
本文介绍了“EAV”或“Class / Concrete Table Inheritance”数据库的设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发建设项目的库存管理系统。店员负责增加新股票,并向员工发放/退回。项目(因此它们的属性)将是非常多样化的;例如钢结构,服装,工厂/机械,工具等。



我的问题是是否要去 Class / Concrete Table Inheritance 或者基于EAV的模式。我不知道什么属性项将具有,所以推测一个Class / Concrete Table Inheritance方法将需要最终用户添加新的表到数据库(这可能吗?)。



请参阅我建议的 EAV模式。这会是一个合理的解决方案吗?我认为我正确的说要识别一个库存项目,有必要在EV表格的查询中执行多个自联接。



注意使用PHP,MySQL和Zend Framework开发

解决方案


  • 更改很少,之间,继续表继承,但是模式的更改应该由您自己或DBA完成。


  • 如果属性更改相当常见,请考虑使用 面向文档的数据库 喜欢 MongoDB CouchDB


  • 如果属性更改是常见的,而您仅限于关系数据库,请使用 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屋!

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