Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone, I need some help here
Background:

My DB need to store YYYY-MM-DD and HH:MM:SS data generated from a Machine. Data will be inserted every few minutes, every day will have Thousands of records

Questions:

Should I separate Date column into another table with DateID and DateName??

What about time? HH:MM:SS, should it be another table or just a column???

How about query performance?? Should I index Date and Time Column with FK????

What's the best pratices for Date and Time stamp??

Thanks for your help in advance.
Posted

The answer is: No! (for separating Date into another table and Time for another table!)

Use one table and proper data type[^] (datetime, datetimeoffset).
 
Share this answer
 
Comments
Member 10689667 22-May-14 17:39pm    
@Maciej Los
Great, thank you, but how about query performance?? it will insert data every few minutes, Should I index Date Column??? I just worry about query performance for user.
Maciej Los 23-May-14 1:41am    
It's good idea to indexing this field.
Member 10689667 23-May-14 9:12am    
Thanks @Maciej Los, Index the DATE Column?? But could you estimate how much it would affect on query performance? Bec index is good for SELECT, but not good for INSERT, and it will insert every few minutes, would it necessary to index??
[no name] 24-May-14 20:06pm    
@Maciej guilty for another five
use datetime or datetime2 [^] and you can create index on datetime column to increase the performance.
http://explainextended.com/2009/11/11/sql-server-clustered-index-and-ordering/[^]
 
Share this answer
 

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