Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL database Data
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 11-Oct-12 19:21pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The second way is preferred, but it all depends on how you intend to use the data.
  Permalink  
Comments
Kuthuparakkal at 12-Oct-12 17:26pm
   
my 5, situation(data consumption) demands the design
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Comments
Maciej Los at 12-Oct-12 17:11pm
   
Agree, +5!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
Comments
Maciej Los at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 623
1 George Jonsson 268
2 OriginalGriff 225
3 CPallini 220
4 PIEBALDconsult 155
0 OriginalGriff 5,865
1 Sergey Alexandrovich Kryukov 5,316
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100