I am thinking of two structures, I don't know which is better or is there are better structure? Im seeking your advise
- Normal structure with code as id and time as string
{ "_id": "AAPL-20220112", "code": "AAPL", "trade_date": "20220112", "open": 17.41, "high": 17.45, "low": 16.9, "close": 17, "pre_close": 17.41, "change": -0.41, "pct_chg": -2.355, "vol": 1502163.55, "amount": 2561266.412 }
- TimeSeries Structure
{ "datetime": { "$date": "2022-01-26T09:31:00.000Z" }, "low": 16.91, "order_book_id": "AAPL", "open": 16.95, "high": 17.08, "num_trades": 1994, "total_turnover": 46092284, "volume": 2713640, "_id": { "$oid": "61f12c8adae836919ca6c665" }, "close": 17.01 }
When work with stocks, I upload data using "update" command, so that repeated data will not be inserted.
And, when pulling data, I use time or stock as index. But hoping the time be already ranked by the database. Using time like string will be hard to rank.
Any suggestions?
date
data type. It allows many advantages - date comparison for sorting, range queries, date arithmetic, and you can get any of the date fields (month, day, year, hour, etc.) from the date field to further work with using date operators. (2) The structure of the data depends upon many factors, mainly, the use case / the application (the kind of operations performed - the important ones), and the amount of data. This is addressed thru the process of Data Modeling.