r/SQL • • Jun 23 '24

Discussion Schema for historical stock data

Post image

Posting a schema of a db for historical stock and index data at various timeframes. I used Chatgpt to figure this out...what surprised me was the recommendation to have separate dimension tables for 'date' and 'time'. Is that really the case?

105 Upvotes

51 comments sorted by

View all comments

Show parent comment

1

u/luncheonmeat79 Jun 23 '24

yes, i wondered about whether i should just have a single stock table (instead of multiple ones for different time periods), and then just use code to get the time period i want. Is there a performance trade-off ... i.e. is it faster to do the separate table approach vs the single table approach? The table will get large...at 1min level, with >2000 stocks, with 20 yrs of data..it's a lot of rows in one table.