简体   繁体   English

在重复情况下将数据存储在数据库中的最佳做法

[英]Best practise on storing data in database for repetitive situations

I am working on upgrading and redesigning logic and data involving weekly delivery schedules. 我正在致力于升级和重新设计涉及每周交付计划的逻辑和数据。

  1. Currently there are integers representing same day, next day or saturday delivery and in the database. 当前,数据库中存在表示当天,第二天或星期六交付的整数。 This uses less rows but more logic (with some hard coded logic for Sundays) 这使用较少的行,但使用更多的逻辑(对于星期日,使用一些硬编码逻辑)
  2. I am thinking of redesigning the table to have a row for each day and its delivery time. 我正在考虑重新设计桌子,以便每天安排一行,并安排交货时间。 This results in more rows in the table but the logic is really easy now. 这将导致表中有更多行,但是逻辑现在很简单。

We have thousands of vendors, delivery schedules, manual interventions, so my redesign would mean the schedule table could quadruple in row count but would allow granular adjustments. 我们有成千上万的供应商,交货计划,人工干预,因此我的重新设计将意味着计划表的行数可以翻两番,但可以进行细微的调整。

Both ways work fine, but what is best terms of best practice? 两种方法都可以正常工作,但是最佳实践的最佳术语是什么?

Is this anything to do with normalization/denormalization, is normalization important here? 这与规范化/非规范化有关吗,规范化在这里重要吗? And if normalization is important, which method is more normalized? 如果归一化很重要,哪种方法更归一化? Or am is this just a matter of opinion? 还是这只是个见解?

There are no universal best practices. 没有通用的最佳做法。 Do what makes sense in your situation. 在您所处的环境中做有意义的事情。 For example, what's more valuable to you: saving disk space and having complicated logic or paying the disk price for clean logic and easy updates? 例如,对您来说更有价值的是:节省磁盘空间并拥有复杂的逻辑,或者为干净的逻辑和容易的更新支付磁盘价格?

Disk space is cheap (and can be unlimited), time* is more expensive and is limited. 磁盘空间便宜(并且可以是无限的),时间*更加昂贵并且受到限制。 Your call. 您的来电。

(* developer salary, time to market, time spent on debugging, etc.) (*开发人员薪水,上市时间,调试时间等)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM