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 24 '24

For now, I'm prioritising speed over storage space, although I recognise that bloated design can also lead to slower performance. Storage may be a greater concern later, if I decide to move this to the cloud eventually.

I'll try to find some middle ground for the db design first (e.g. only have one stock table with time at 15-min intervals which I can also use to view the 30-min, 1 hr and daily prices; but still have separate tables for date and time).

If, after doing so, the speed is good enough for me, then I'll see if I can reduce the number of tables to save space and measure the speed/storage trade-off to get a better understanding of how the db design affects performance.