Forum Moderators: open
symbol_DDMMYYYY
And it has a row for every minute in a certain day, containing the data. So each UTC day has roughly 1440 rows, and is in a separate table.
Is this a good scalable structure for storing the data?
ed
There should be one main table not a table per day.
The table should have a time stamp field and then any data that relates to it either in a seperate field or in a lookup table using Ids depending on what you are storing. This way you can track many items in one table, index the id, yes the data will get huge.... that is what databases are for.... you can archive every month or year or whatever and empty the tables and start fresh if you have to..
Something like this
TABLE: Price_Data_Track
pdt_id (int, pKey) ¦ date_time(timestamp) ¦ item_id (int) ¦ price (float)
---------------------------------------------------------------
1 ¦ 2008-07-24 01:18:47.973713 ¦ 0987 ¦ 89.76
2 ¦ 2008-07-24 01:19:47.973713 ¦ 0987 ¦ 89.99
3 ¦ 2008-07-24 01:20:47.973713 ¦ 0987 ¦ 90.01
4 ¦ 2008-07-24 01:21:47.973713 ¦ 0987 ¦ 88.76
5 ¦ 2008-07-24 01:18:47.973713 ¦ 3456 ¦ 67.76
6 ¦ 2008-07-24 01:19:47.973713 ¦ 3456 ¦ 67.99
7 ¦ 2008-07-24 01:20:47.973713 ¦ 3456 ¦ 68.01
8 ¦ 2008-07-24 01:21:47.973713 ¦ 3456 ¦ 66.76
TABLE: Items
item_id (int, pKey) ¦ item_name ¦ item_desc
--------------------------------------------
0987 ¦ widgets ¦ things to plug into places
3456 ¦ doohickee ¦ a whatcha-ma-call-it
Having different tables for different dates did seem wrong to me since the data needs to be used for many timezones and this means making more queries as the data needed will span more than one table.
Would I not have different tables for different products at least (there will only ever be less than 10)?
Do some reading and ask around because getting as much info as you can is always a good thing and learning about this won't hurt either, but I do this type of thing a lot and it may not be the best way but I am sure there isn't a much better way other then storing it in a flat file like a website log would be.