通用数据库表 [英] Generic DB Table

查看:156
本文介绍了通用数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下数据库表设计有任何名称:



基本上,我们有表示键/值对的通用列。



id | k1 | v1 | k2 | v2 | k3 | v3 | ....



1 |名称| sam | last_name |史密斯| NULL | NULL | ...



在我的应用程序中,我有很多表只有一行,我想将它们合并成一个通用表,表示单个表行的行。



提前感谢。

解决方案

Entity-Attribute-Value。也称为名称 - 值表或开放模式。

href =http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back =noreferrer> SQL反模式。它失败了关系数据库设计的许多规则,它是难以置信的难以维护。我建议反对它。



在我回答问题产品表,多种产品,每个产品都有很多参数。


Is there any name for the following DB table design:

Basically we have generic columns representing key/value pair.

id | k1 | v1 | k2 | v2 | k3 | v3 | ....

1 | name | sam | last_name| smith | NULL | NULL | ...

In my application, I have many tables that have only one row and I would like to merge them into a generic table that has X number of columns with each rows representing singular table rows.

Thanks in advance.

解决方案

Entity-Attribute-Value. Also called a "Name-Value Table" or an "Open Schema."

This is an SQL Antipattern. It fails many rules of relational database design, and it's incredibly hard to maintain. I recommend against it.

See more of my thoughts about EAV in my answer to the question "Product table, many kinds of product, each product has many parameters."

这篇关于通用数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆