Click here to Skip to main content
Sign Up to vote bad
good
See more: SQLdatabaseData
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:21


3 solutions

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

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 223
1 Ron Beyer 220
2 Aarti Meswania 200
3 Mahesh Bailwal 175
4 Rohan Leuva 170
0 Sergey Alexandrovich Kryukov 8,553
1 OriginalGriff 6,899
2 CPallini 3,648
3 Rohan Leuva 2,963
4 Maciej Los 2,308


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