這只是一個數據庫概念問題:以下EAV模型有哪些優缺點?數據庫設計:EAV選項?
模型1:
TABLE: attribute_value
======================================
| id | fk_id | attribute | value |
======================================
| 1 | 10 | FName | John |
| 2 | 10 | Lname | Doe |
| 3 | 55 | FName | Bob |
| 4 | 55 | Lname | Smith |
--------------------------------------
模型2:
TABLE: attribute
==================
| id | attribute |
==================
| 1 | FName |
| 2 | Lname |
------------------
TABLE: value
=====================================
| id | attribute_id | fk_id | value |
=====================================
| 1 | 1 | 10 | John |
| 2 | 2 | 10 | Doe |
| 3 | 1 | 55 | Bob |
| 4 | 2 | 55 | Smith |
-------------------------------------
一個好處我與模型2看到的是attribute
不包含重複。
缺點:EAV真的很難優化。過了一段時間,您會遇到無法寫入的查詢,以至於無法正常工作。 – zerkms