这样的设计有它的好处,Magento(一开源商城程序)属性的一张表的结构和表一是一样的
这种数据库的设计称作EVA
引自《php|architect’s Guide to Programming Magento》
引用:
"Magento’s database design is one of its most controversial aspects. Key data are modeled using the Entity Attribute Value method (EAV). Utilizing an EAV modeling pattern allows for unlimited attributes on any product, category, customer, or order, but EAV also depletes a programmer’s ability to write ad-hoc queries against the data"
引自《php|architect’s Guide to Programming Magento》
引用:
“As you can see from looking at the chart, adding a new attribute to a user simply involves adding a new record in the eav_attribute table. Adding a new attribute does not involve altering tables to add any new columns. This opens the door for graphical interfaces to easily manage adding new attributes to most parts of the system, while keeping the database schema consistent across installations. Notice that the eav_attribute table has extra type information. In EAV systems, the key to having a flexible, workable system is meta-data about the attributes. Adding more columns to eav_attribute could allow for information about the attributes,like how attributes are grouped together, whether or not values are required, or if the attribute should be restricted to certain entity types (should you allow “first_name” for a product, or just a user?).
One downside to working with an EAV database is that the table design seems too loose. There is not one single source for the definition of a user that can easily be ”
常规的表设计

EAV模式的表设计
[
本帖最后由 irlvirus 于 2008-8-12 15:28 编辑 ]