简体   繁体   English

如何在关系数据库中存储自定义实体属性

[英]How to store custom entity properties in a relational database

I'm designing a database for a application I'm developing. 我正在为正在开发的应用程序设计数据库。

I have two tables where the entities can have custom application properties that will define how the data from each entity is used. 我有两个表,其中实体可以具有自定义应用程序属性,这些属性将定义如何使用每个实体的数据。

Each entity can have zero to many properties and i want to know what the best way is to structure such data in a relational way. 每个实体可以具有零到许多属性,我想知道最好的方法是以关系方式构造此类数据。 Should i have one table with foreign keys to each table and key/value columns or is there some better way to do it? 我应该在一个表中使用外键指向每个表和键/值列,还是有更好的方法呢?

You are speaking of "Entity Attribute Value" tables. 您说的是“实体属性值”表。

Entity Tables: 实体表:

Ent1 (Eid, name, desc, etc...)
Ent2 (Eid, name, desc, etc...)

Attribute (EAV) Tables: 属性(EAV)表:

Ent1Props (id, Eid, att, value)
Ent2Props (id, Eid, att, value)

You can combine the two EAV tables into one and that creates a MUCK (Massive Unified Code Key) table. 您可以将两个EAV表合并为一个,然后创建一个MUCK(大型统一代码密钥)表。 But don't do that as it has some real drawbacks in the long run. 但是不要这样做,因为从长远来看它有一些实际的缺点。 Nearly everyone has tried it at one point because it seems easy at first, but it becomes a monster. 几乎每个人都曾经尝试过它,因为乍一看似乎很容易,但它却变成了怪物。

Key value pairs in relational database 关系数据库中的键值对

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您在关系数据库中的哪里存储临时属性? - Where do you store ad-hoc properties in a relational database? 如何在关系数据库中存储不同版本的数据? - How to store different version of data in a relational database? 如何在关系数据库中存储滚动周的展示次数? - How to store a rolling week of impressions in a relational database? 如何在关系数据库中存储以下结构? - How to store the following structure in a relational database? 实体框架 - 如何过滤渴望加载的导航/关系属性? - Entity framework - how to filter eager loaded navigational/relational properties? 没有关系数据库的 ACID 属性如何帮助非关系数据库性能更好? - How not having the ACID properties of a Relational database helps Non-relational database perform better? 如何在关系数据库中存储二进制空间分区树? - How can I store a binary space partitioning tree in a relational database? 如何在关系数据库中存储原始数据的可编辑副本? - How to store editable copies of original data in a relational database? 如何在关系数据库中存储智能列表规则 - How to store smart-list rules in a relational database 关系数据库中的自定义类型系统 - Custom type system in relational database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM