Entity Attribute Value Database vs. strict Relational Model Ecommerce

前端 未结 10 1348
谎友^
谎友^ 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

    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.

提交回复
热议问题