关于非规范化的问题 [英] question about about denormalization

查看:129
本文介绍了关于非规范化的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们对数据库进行规范化时,为什么需要取消规范化?

when we normalize the database why we need to denormalize?

推荐答案

规范化可以确保数据不是冗余的,这是一件好事.但这也可能是不好的.

考虑这个例子.假设有一个银行帐户数据库.并想象有一个与帐户有关的表(表)和与交易有关的另一个表.

我们不需要ACCOUNT_BALANCE列,因为我们总是可以通过对交易进行汇总来得出帐户余额.但是...

如果我们以这种方式获得帐户余额,则每次检索帐户余额时,都会对数据库执行大量操作.当帐户记录"和交易记录"的数量变大时,计算将变得越来越密集.

这是取消规范化数据库并在帐户"表中具有ACCOUNT_BALANCE列的充分理由.

希望您能理解.
Normalization makes sure that the data is not redundant, which is a good thing. But this can be bad as well.

Consider this example. Say there is a database for bank accounts. And imagine that there is a relation (table) for Account, and another relation for Transactions.

We do not need to have an ACCOUNT_BALANCE column, because we can always derive the account balance from summing up the transactions. But...

If we get the account balance in this way, every time the account balance is retrieved, a huge operation is performed on the database. When the number of Account records and Transaction records gets bigger, the computation gets intensive.

That''s a good reason to de-normalize the database and have an ACCOUNT_BALANCE column in Account table.

I hope you get the idea.


去规范化是一项旨在提高数据库性能的工作.它不是(也不应该)试图消除数据完整性的目标,而是试图在保持数据完整性的同时优化性能.

这应该有帮助:
了解非规范化之前的规范化 [
Denormalization is an effort to improve the performance of a database. It does not (and should not) seek to eliminate the goal of data integrity, but instead seeks to optimize performance while maintaining data integrity.

This should help:
Understand Normalization Before Denormalizing[^]


这篇关于关于非规范化的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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