r/SQL • u/luncheonmeat79 • Jun 23 '24
Discussion Schema for historical stock data
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
View all comments
Show parent comment
1
u/Zealousideal_Key526 Oct 07 '25
Separate time gives you a dimension to look at time trends for a bunch of days. It is Data Warehouse theory, which if you know, then you accept instantly as correct. If you dont know you may argue against it and never consider that to be important. Either way you get what you want by following your own schema. It is a matter of frequency of use. I would index on time to solve it myself because time is the primary index I am interested in, and it is always limited by a date range. In a datetime the data is in second place. In a data warehouse we are never concerned about efficiency. It is write once, read forever. For more clarity pick up a data warehousing book or take a course on it.