Entity Attribute Value Database vs. strict Relational Model Ecommerce

前端 未结 10 1347
谎友^
谎友^ 2020-11-22 05:23

It is safe to say that the EAV/CR database model is bad. That said,

Question: What database model, technique, or pattern should be used to deal with \"clas

相关标签:
10条回答
  • 2020-11-22 06:04
    // At this point, I'd like to take a moment to speak to you about the Magento/Adobe PSD format.
    // Magento/PSD is not a good ecommerce platform/format. Magento/PSD is not even a bad ecommerce platform/format. Calling it such would be an
    // insult to other bad ecommerce platform/formats, such as Zencart or OsCommerce. No, Magento/PSD is an abysmal ecommerce platform/format. Having
    // worked on this code for several weeks now, my hate for Magento/PSD has grown to a raging fire
    // that burns with the fierce passion of a million suns.
    

    http://code.google.com/p/xee/source/browse/trunk/XeePhotoshopLoader.m?spec=svn28&r=11#107

    The internal models are wacky at best, like someone put the schema into a boggle game, sealed that and put it in a paint shacker...

    Real world: I'm working on a midware fulfilment app and here are one the queries to get address information.

    CREATE OR REPLACE VIEW sales_flat_addresses AS
    SELECT sales_order_entity.parent_id AS order_id, 
           sales_order_entity.entity_id, 
           CONCAT(CONCAT(UCASE(MID(sales_order_entity_varchar.value,1,1)),MID(sales_order_entity_varchar.value,2)), "Address") as type, 
           GROUP_CONCAT( 
             CONCAT( eav_attribute.attribute_code," ::::: ", sales_order_entity_varchar.value )
             ORDER BY sales_order_entity_varchar.value DESC
             SEPARATOR '!!!!!' 
           ) as data
      FROM sales_order_entity
           INNER JOIN sales_order_entity_varchar ON sales_order_entity_varchar.entity_id = sales_order_entity.entity_id
           INNER JOIN eav_attribute ON eav_attribute.attribute_id = sales_order_entity_varchar.attribute_id
       AND sales_order_entity.entity_type_id =12
     GROUP BY sales_order_entity.entity_id
     ORDER BY eav_attribute.attribute_code = 'address_type'
    

    Exacts address information for an order, lazily

    --

    Summary: Only use Magento if:

    1. You are being given large sacks of money
    2. You must
    3. Enjoy pain
    0 讨论(0)
  • 2020-11-22 06:04

    I have a slightly different problem: instead of many attributes with sparse values (which is possibly a good reason to use EAV), I want to store something more like a spreadsheet. The columns in the sheet can change, but within a sheet all cells will contain data (not sparse).

    I made a small set of tests to benchmark two designs: one using EAV, and the other using a Postgres ARRAY to store cell data.

    EAV

    Array

    Both schemas have indexes on appropriate columns, and the indexes are used by the planner.

    It turned out the array-based schema was an order of magnitude faster for both inserts and queries. From quick tests, it seemed that both scaled linearly. The tests aren't very thorough, though. Suggestions and forks welcome - they're under an MIT licence.

    0 讨论(0)
  • 2020-11-22 06:05

    I still vote for modeling at the lowest-meaningful atomic-level for EAV. Let standards, technologies and applications that gear toward certain user community to decide content models, repetition needs of attributes, grains, etc.

    0 讨论(0)
  • 2020-11-22 06:09

    If it's just about the product catalog attributes and hence validation requirements for those attributes are rather limited, the only real downside to EAV is query performance and even that is only a problem when your query deals with multiple "things" (products) with attributes, the performance for the query "give me all attributes for the product with id 234" while not optimal is still plenty fast.

    One solution is to use the SQL database / EAV model only for the admin / edit side of the product catalog and have some process that denormalizes the products into something that makes it searchable. Since you already have attributes and hence it's rather likely that you want faceting, this something could be Solr or ElasticSearch. This approach avoids basically all downsides to the EAV model and the added complexity is limited to serializing a complete product to JSON on update.

    0 讨论(0)
提交回复
热议问题