热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何处理宽平台的列增长-Howtohandlecolumngrowthofwide,flattables

HowwouldyouDBAshandlethis?Ihavetakenownershipofanexistingapp(VB6)anddatabasethatw

How would you DBA's handle this? I have taken ownership of an existing app (VB6) and database that was written in 1999. The database design is fairly 'flat', meaning the main tables are fairly wide (100+ columns) and developers have continued to tack on additional columns to the end of the tables. This has resulted in columns that have a lot of Nulls since they don't directly relate to the primary key.

DBA如何处理这个问题?我已经获得了1999年编写的现有应用程序(VB6)和数据库的所有权。数据库设计相当“平坦”,这意味着主要表格相当宽(100多列),开发人员继续将其他列添加到表的结尾。这导致列具有大量Null,因为它们与主键没有直接关系。

I am considering splitting the main table out as a way to abstract myself from the years and years of 'column explosion'. I am certain that new fields will continue to be added as new requirements come up.

我正在考虑拆分主表,以便从多年来的“列爆炸”中抽象出自己。我确信随着新要求的出现,新领域将继续增加。

So the question is, as new fields are needed, do you continue to grow the width of the existing table? Or do you STOP extending an existing table and split it out into a separate supporting table that will house new fields, thereby creating a 1-to-1 relationship? If you were to split the main table, what would your naming scheme be?

所以问题是,由于需要新字段,您是否继续增加现有表的宽度?或者你停止扩展现有的表并将其拆分成一个单独的支持表,它将容纳新的字段,从而创建一对一的关系?如果您要拆分主表,您的命名方案是什么?

Let's assume for this example I have a table called 'Foreclosure' with 150 fields. What is a good name for the new 1-to-1 table? 'ForeclosureExtended'? ForeclosureOtherInfo'?

让我们假设这个例子我有一个名为'Foreclosure'的表,有150个字段。新的1对1桌子有什么好名字? 'ForeclosureExtended'? ForeclosureOtherInfo“?

By the way, there are Views and Stored Procs that will need to be modified to support any new tables, but that is inevitable anyway when columns are added.

顺便说一下,有些视图和存储过程需要修改以支持任何新表,但是当添加列时,这是不可避免的。

thanks in advance for any thoughts.

提前感谢任何想法。

3 个解决方案

#1


80% of the time, your nulls have definite patterns.

80%的情况下,您的空值具有明确的模式。

These patterns define subclasses of your table. In your case, they will be subclasses of Foreclosure.

这些模式定义了表的子类。在您的情况下,它们将是止赎的子类。

Your splitting should be based on these subclass relationships.

您的拆分应该基于这些子类关系。

Say, for example, some Foreclosure instances have a bunch of fields related to legal proceeding that are nearly all filled in. And other Foreclosure instances have the legal proceeding fields entirely filled with nulls.

比如说,例如,一些止赎实例有一堆与法律诉讼相关的字段几乎全部填写。而其他止赎实例的法律诉讼字段完全填充了空值。

You have two classes. You need to work out the relationship between them -- are they superclass-subclass or are they peer subclasses of some other superclass?

你有两节课。你需要弄清楚它们之间的关系 - 它们是超类 - 子类还是它们是某些其他超类的对等子类?

This tells you how to partition your table to make useful stuff happen.

这告诉您如何对表进行分区以使有用的东西发生。

  • You may have proper superclass subclass relationships

    您可能具有适当的超类子类关系

  • You may have found a thing (a LegalProceeding) which should have been a separate table all along. It should not have been permanently joined into Foreclosure. This is remarkably common.

    你可能已经找到了一个东西(一个LegalProceeding),它应该一直是一个单独的表。它不应该永久地加入止赎。这非常普遍。

You now have some relational implementation choices.

您现在有了一些关系实现选择。

  • One common choice is to put all subclasses into a single, massive table with a lot of nulls. This is what you have today, and it isn't working.

    一个常见的选择是将所有子类放入一个包含大量空值的单个大型表中。这就是你今天所拥有的,它无法正常工作。

  • One choice is to split the two subclass relationship tables into peers, duplicating the common information.

    一种选择是将两个子类关系表拆分为对等,复制公共信息。

  • One choice is to have a superclass table with an optional FK reference to the additional information in the subclass.

    一种选择是拥有一个超类表,其中包含对子类中其他信息的可选FK引用。

  • One choice is to have a subclass table with a mandatory FK reference to the superclass information.

    一种选择是使子类表具有对超类信息的强制FK引用。

#2


Unless you are really brave, app is very small/simple, or there are major performance issues do not fix the schema. If it ain't broke, don't fix it.

除非你真的很勇敢,否则应用程序非常小/简单,或者存在重大性能问题而无法修复架构。如果没有损坏,请不要修理它。

Just create a new table ForeclosureExtended, as you suggest with the same key and start adding columns. Or, you could make proper tables with grouped columns as new columns appear. Either way, if the schema is this bad, I'll bet the code is very fragile.

只需创建一个新表ForeclosureExtended,就像您建议使用相同的密钥并开始添加列。或者,当出现新列时,您可以使用分组列创建正确的表。无论哪种方式,如果架构这么糟糕,我敢打赌代码非常脆弱。

#3


Why do you feel that you have a problem? To my mind it's easier to deal with one table that has a lot of columns than it is to deal with a ton of narrower tables and all the associated views you have to maintain.

为什么你觉得你有问题?在我看来,处理一个包含大量列的表比处理大量较窄的表以及您必须维护的所有相关视图更容易。


推荐阅读
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • 本文介绍了如何使用Power Design(PD)和SQL Server进行数据库反向工程的方法。通过创建数据源、选择要反向工程的数据表,PD可以生成物理模型,进而生成所需的概念模型。该方法适用于SQL Server数据库,对于其他数据库是否适用尚不确定。详细步骤和操作说明可参考本文内容。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 本文详细介绍了如何使用MySQL来显示SQL语句的执行时间,并通过MySQL Query Profiler获取CPU和内存使用量以及系统锁和表锁的时间。同时介绍了效能分析的三种方法:瓶颈分析、工作负载分析和基于比率的分析。 ... [详细]
  • 本文讨论了在使用sp_msforeachdb执行动态SQL命令时,当发生错误时如何捕获数据库名称。提供了两种解决方案,并介绍了如何正确使用'?'来显示数据库名称。 ... [详细]
  • 一、Hadoop来历Hadoop的思想来源于Google在做搜索引擎的时候出现一个很大的问题就是这么多网页我如何才能以最快的速度来搜索到,由于这个问题Google发明 ... [详细]
  • 本文详细介绍了SQL日志收缩的方法,包括截断日志和删除不需要的旧日志记录。通过备份日志和使用DBCC SHRINKFILE命令可以实现日志的收缩。同时,还介绍了截断日志的原理和注意事项,包括不能截断事务日志的活动部分和MinLSN的确定方法。通过本文的方法,可以有效减小逻辑日志的大小,提高数据库的性能。 ... [详细]
  • Oracle Database 10g许可授予信息及高级功能详解
    本文介绍了Oracle Database 10g许可授予信息及其中的高级功能,包括数据库优化数据包、SQL访问指导、SQL优化指导、SQL优化集和重组对象。同时提供了详细说明,指导用户在Oracle Database 10g中如何使用这些功能。 ... [详细]
  • 本文详细介绍了MysqlDump和mysqldump进行全库备份的相关知识,包括备份命令的使用方法、my.cnf配置文件的设置、binlog日志的位置指定、增量恢复的方式以及适用于innodb引擎和myisam引擎的备份方法。对于需要进行数据库备份的用户来说,本文提供了一些有价值的参考内容。 ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • 本文介绍了一个在线急等问题解决方法,即如何统计数据库中某个字段下的所有数据,并将结果显示在文本框里。作者提到了自己是一个菜鸟,希望能够得到帮助。作者使用的是ACCESS数据库,并且给出了一个例子,希望得到的结果是560。作者还提到自己已经尝试了使用"select sum(字段2) from 表名"的语句,得到的结果是650,但不知道如何得到560。希望能够得到解决方案。 ... [详细]
  • 本文讨论了在数据库打开和关闭状态下,重新命名或移动数据文件和日志文件的情况。针对性能和维护原因,需要将数据库文件移动到不同的磁盘上或重新分配到新的磁盘上的情况,以及在操作系统级别移动或重命名数据文件但未在数据库层进行重命名导致报错的情况。通过三个方面进行讨论。 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
  • web.py开发web 第八章 Formalchemy 服务端验证方法
    本文介绍了在web.py开发中使用Formalchemy进行服务端表单数据验证的方法。以User表单为例,详细说明了对各字段的验证要求,包括必填、长度限制、唯一性等。同时介绍了如何自定义验证方法来实现验证唯一性和两个密码是否相等的功能。该文提供了相关代码示例。 ... [详细]
  • 本文介绍了Python爬虫技术基础篇面向对象高级编程(中)中的多重继承概念。通过继承,子类可以扩展父类的功能。文章以动物类层次的设计为例,讨论了按照不同分类方式设计类层次的复杂性和多重继承的优势。最后给出了哺乳动物和鸟类的设计示例,以及能跑、能飞、宠物类和非宠物类的增加对类数量的影响。 ... [详细]
author-avatar
手机用户2502936521
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有