我正計劃爲自己的目的從CoinMarketCap API保存記錄。 我想每隔15分鐘將價格信息保存在前100個加密硬幣上,我想將它保存在Azure Cosmos數據庫中。建模Azure Cosmos DB
由於im新的文檔db的整個概念,我需要一些建模文檔的幫助。
首先我從這個模型開始。
[
{
"id": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_usd": "573.137",
"price_btc": "1.0",
"24h_volume_usd": "72855700.0",
"market_cap_usd": "9080883500.0",
"available_supply": "15844176.0",
"total_supply": "15844176.0",
"percent_change_1h": "0.04",
"percent_change_24h": "-0.3",
"percent_change_7d": "-0.57",
"last_updated": "1472762067"
},
{
"id": "ethereum",
"name": "Ethereum",
"symbol": "ETH",
"rank": "2",
"price_usd": "12.1844",
"price_btc": "0.021262",
"24h_volume_usd": "24085900.0",
"market_cap_usd": "1018098455.0",
"available_supply": "83557537.0",
"total_supply": "83557537.0",
"percent_change_1h": "-0.58",
"percent_change_24h": "6.34",
"percent_change_7d": "8.59",
"last_updated": "1472762062"
},
...
]
但是,由於每次我寫入數據庫時id都沒有變化,記錄只是更新了,而沒有彙總。我想這是預期的。
因此,爲了確保記錄彙總,我重寫了這個模型。
[
{
"id": <timestamp>_bitcoin
"identifier": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_usd": "573.137",
"price_btc": "1.0",
"24h_volume_usd": "72855700.0",
"market_cap_usd": "9080883500.0",
"available_supply": "15844176.0",
"total_supply": "15844176.0",
"percent_change_1h": "0.04",
"percent_change_24h": "-0.3",
"percent_change_7d": "-0.57",
"last_updated": "1472762067"
},
{
"id": <timestamp>_ethereum
"identifier": "ethereum",
"name": "Ethereum",
"symbol": "ETH",
"rank": "2",
"price_usd": "12.1844",
"price_btc": "0.021262",
"24h_volume_usd": "24085900.0",
"market_cap_usd": "1018098455.0",
"available_supply": "83557537.0",
"total_supply": "83557537.0",
"percent_change_1h": "-0.58",
"percent_change_24h": "6.34",
"percent_change_7d": "8.59",
"last_updated": "1472762062"
},
...
]
在這裏,我以使其獨特添加了一個單獨的id
帶有時間戳和參考舊ID。
這是行得通的,但我認爲這是一些重複的數據(如名稱和符號),我認爲這看起來不好,有雙重。但也許這就是它在文檔db世界中的方式?
我也想過這樣的模型。
[
{
"id": <timestamp>_bitcoin
"identifier": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_history": [{
"price_usd": "573.137",
"price_btc": "1.0",
"24h_volume_usd": "72855700.0",
"market_cap_usd": "9080883500.0",
"available_supply": "15844176.0",
"total_supply": "15844176.0",
"percent_change_1h": "0.04",
"percent_change_24h": "-0.3",
"percent_change_7d": "-0.57",
"last_updated": "1472762067"
]}
},
{
"id": <timestamp>_ethereum
"identifier": "ethereum",
"name": "Ethereum",
"symbol": "ETH",
"rank": "2",
"price_history": [{
"price_usd": "12.1844",
"price_btc": "0.021262",
"24h_volume_usd": "24085900.0",
"market_cap_usd": "1018098455.0",
"available_supply": "83557537.0",
"total_supply": "83557537.0",
"percent_change_1h": "-0.58",
"percent_change_24h": "6.34",
"percent_change_7d": "8.59",
"last_updated": "1472762062"
]}
},
...
]
但由於沒有選擇新的記錄添加到price_history
無需重寫整個文件,這不會是一個好主意。此外,由於price_history
中的記錄數量將無限制地增長,因此該文檔將變得非常龐大且難以處理。
接下來我想分解成單獨的文件,但不知道如果這是要走的路。所以我現在有點迷路了。
有什麼建議嗎?
你能在你的每cryptocurrency聚集的價格信息(如果有的話)的要求詳細點嗎?或者是你只需要記錄每個時間戳最後一小時,一天和一週的百分比變化? –
我想保留歷史數據以便分析它。一個例子就是及時檢查新聞對價格變化或其他類似情景的影響。還想玩Azure機器學習,並且爲了使用我需要的一些數據來分析。 – Martin