Click here to Skip to main content
15,886,714 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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?
Posted

The second way is preferred, but it all depends on how you intend to use the data.
 
Share this answer
 
Comments
Kuthuparakkal 12-Oct-12 17:26pm    
my 5, situation(data consumption) demands the design
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
 
Share this answer
 
Comments
Maciej Los 12-Oct-12 17:11pm    
Agree, +5!
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.
 
Share this answer
 
Comments
Maciej Los 12-Oct-12 17:11pm    
Agree, +5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900