如何建模具有未知属性的数据? [英] How to model data with unknown attributes?

查看:190
本文介绍了如何建模具有未知属性的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于需要查询的数据进行建模的好方法是什么?在哪里不可能完全定义前端?



例如...说我想关于世界各国的模型信息。每个国家/地区都有人口标志语言列表,这很简单。但是说我们也想模仿他们国家棒球队的胜负记录,当然不是所有的国家都有一个。或者,我们想跟踪他们的国王&皇后(再次显然不适用于大多数国家)。或者,我们决定我们要模拟平均部落成员在一生中直立的蒙古包数量。无论如何,无论如何,无论如何,我们不会(而且永远不会)知道到达我们之前会发生什么。哪些方法既可扩展又可查询?



这可能对于以以文档为中心的数据库MongoDB?)或者一些设计模式可以应用于经典的关系数据库?

解决方案

你可以在一个纯粹的关系数据库中做到这一点,享受关系数据库的速度和力量。



您需要使用第六个正常表单,正确的方法具有完整的完整性和控制权。



EAV是一个子集的6NF没有完整性或控制权,并且通常非常糟糕的实现。



我对这些问题的回答提供了对该主题的完整的处理。由于提出的背景和论点,最后一个特别长。



EAV-6NF答案一

EAV-6NF答案二

EAV-6NF答案三


What are good ways to model data that will need to be queried but where it's impossible to fully define up front?

For instance... say I want to model information about the countries of the world. Each country has a population, a flag and a list of languages, that's easy enough. But say we also want to model the win/loss record of their national baseball team and not all countries have one, of course. Or, we want to track the lineage of their kings & queens (again, obviously not applicable to most countries). Or, we decide we want to model the number of yurts the average clan member will erect in a lifetime.

Anyway, point is, we don't (and won't ever) know what's coming until it hits us. What approaches are there that are both scalable and query-able?

Is this, perhaps, a good use for a Document-centric database (MongoDB?) or perhaps some design pattern could be applied to the classic Relational database?

解决方案

You can do that in a pure Relational Database, and enjoy the speed and power of Relational databases.

You need to use Sixth Normal Form, the proper method with full integrityand control.

EAV is a subset of 6NF without the Integrity or control, and usualy very badly implemented.

My answers to these questions provide a full treatment of the subject. The last one is particularly long due the the context and arguments raised.

EAV-6NF Answer One
EAV-6NF Answer Two
EAV-6NF Answer Three

这篇关于如何建模具有未知属性的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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