You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

含metric_name与metric_value列的转置表是否有标准命名?

Entity-Attribute-Value (EAV) Model: The Standard Name for Transposed Dynamic Tables

Hey there! That transposed table structure you're describing has a widely recognized standard name: Entity-Attribute-Value (EAV) Model.

Let me break this down clearly:

  • A typical "wide" or flat database table stores all attributes of an entity as columns, with one row representing a complete record of that entity.
  • The EAV model flips this paradigm entirely: each row represents just a single attribute-value pair for an entity. It relies on three core columns to organize data:
    • entity_id: A unique identifier for the entity being tracked
    • attribute_name: The name of the metric/attribute being recorded
    • attribute_value: The actual value associated with that attribute

As you noted, EAV shines when the number of collected metrics changes frequently. Unlike wide tables, which require altering the table schema (via ALTER TABLE commands) every time you add or remove a metric, EAV lets you simply add or remove rows to accommodate new attributes—no schema changes needed.

It’s worth noting that EAV has trade-offs too:

  • Querying multiple attributes for an entity often requires joining the table to itself multiple times or using aggregate functions, which can be less performant than querying a wide table.
  • The attribute_value column usually needs to be a generic data type (like VARCHAR) to support different metric types, which can complicate data validation and type consistency.

内容的提问来源于stack exchange,提问作者user2989038

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:26:10