最佳数据库设计,可记录任务之间经过的时间 [英] Best database design for logging time elapsed between tasks

查看:82
本文介绍了最佳数据库设计,可记录任务之间经过的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在设计一个数据库,用于测量在一项项目上执行某些任务之间经过的时间.

我有两种选择可以做到这一点,但我不知道哪一种是我的最佳选择:

第一:

设计一个表,其中每个测量参数都有一个专用字段,以便对包含所有测量参数的特定项目使用一行.

示例:

 ItemId | TimeTask1 | TimeTask2 | TimeTask3 | TimeTask4 | ... | TimeTaskN 



第二:

设计一个具有通用字段的表,为每个测量参数留一行,并标识它们所属的实际任务.

示例:

 ItemId | TaskId |时间已过去



解决方案

首选第二种方法,但这完全取决于您打算如何使用数据.


您好,

我认为第二种方法是好的方法.第一种方式存在缺陷.我们无法确定
在特定项目上要执行多少个任务.除了TaskN ...之外,还有其他功能...如果您以第一种方式设计表格,那么任务计数是固定的.然后,我们必须在表中添加一列以存储taskN + 1 ..... taskN + N花费的时间.所以第二种方式适合您的要求.

谢谢


第二种方法是首选的(标准化)方法.
另外,您可以在任务完成时为任务添加一行,您的应用程序无需等待所有任务完成就可以将其写入数据库.


Hi guys,

I''m designing a database for measure time elapsed between the execution of some tasks over an item.

I have two options to do this, but I don´t know which one is my best choice:

First:

Design a table with a dedicated field for each measurement parameter, to have a single row for a specific item with all the measurement parameters.

Example:

ItemId | TimeTask1 | TimeTask2 | TimeTask3 | TimeTask4 | ... | TimeTaskN



Second:

Design a table with generic fields, to have a row for each measurement parameter and identify the actual task they belong to.

Example:

ItemId | TaskId | TimeElapsed



What do you think?

解决方案

The second way is preferred, but it all depends on how you intend to use the data.


Hi,

I think second way is good approach. There is a flaw in first way. We can''t determine
how many task will be performed on particular item. There can more than TaskN... If you design your table in first way then task count is fixed. Then We have to add a column to the table to store time taken by taskN+1..... taskN+N. So second way suits to your requirement.

Thank you


The second option is the preferred (normalized) way to do it.
As a bonus you can add a row for a task whenever it''s done, your application does not need to wait for all tasks to be done before it can write it to the database.


这篇关于最佳数据库设计,可记录任务之间经过的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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