introduction
The design philosophy of the EAV (Entity-Attribute-Value) database is to store data as a set of attribute-value pairs associated with an entity. This model has flexibility in data storage and querying, especially when processing historical data. However, traditional EAV designs often face challenges in data integrity, report generation, and performance.
Solve common EAV defects
To overcome these shortcomings, it is possible to consider separating different entity attributes according to the attribute type. This method has the following advantages:
Example Relational Database Management System (RDBMS) Schema Design
]The following RDBMS pattern design demonstrates how to implement this approach:
entity_type: Storage entity type (for example, "Product", "User") entity: represents the main entity table attr: Associate attributes with entities option: Options for storing attribute-value pairs attr_option: Link options to attribute-value pairs attr_int: Stores integer attribute values attr_relation: Stores the relationship with other entities attr_datetime: Store date and time attribute values attr_string: Store string attribute values attr_text: Stores text attribute values attr_decimal: Stores decimal attribute values
This mode allows the storage of historical data by inserting a new attribute-value pair every time the attribute value changes.
Advantages of the proposed method
]Potential Issues
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3