Extendable Database Schema - How to store the extendable attribute values

前端 未结 2 478
长情又很酷
长情又很酷 2021-01-15 02:40

We are using SQL Server 2008 and one of the requirements is to have extendable user defined attributes on the entities that are defined for the system. For example, we migh

相关标签:
2条回答
  • 2021-01-15 02:59

    Here are just a few SO questions/answers relevant to the topic.

    • One
    • Two
    • Three
    0 讨论(0)
  • 2021-01-15 03:00

    Based on the link the @gbn sent me in the comments, I think this is an effective answer (Taken from the WIKI link):

    The Value

    Coercing all values into strings, as in the EAV data example above, results in a simple, but non-scalable, structure: constant data type inter-conversions are required if one wants to do anything with the values, and an index on the value column of an EAV table is essentially useless. Also, it is not convenient to store large binary data, such as images, in Base64 encoded form in the same table as small integers or strings. Therefore larger systems use separate EAV tables for each data type (including binary large objects, "BLOBS"), with the metadata for a given attribute identifying the EAV table in which its data will be stored. This approach is actually quite efficient because the modest amount of attribute metadata for a given class or form that a user chooses to work with can be cached readily in memory. However, it requires moving of data from one table to another if an attribute’s data type is changed. (This does not happen often, but mistakes can be made in metadata definition just as in database schema design.)

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