1
在SQL我通常會對錶/實體Account
和AccountDetails
,Address
等NoSQL的文檔結構VS SQL表結構
Account { Id, Name, Password }
AccountDetails { AccountId, LastSignedIn, CreatedDate, /*etc*/}
Address {AccountDetailsId, City, Country, /*etc*/ }
在的NoSQL數據庫的類型,我應該存儲所有在一個?
Account { Id, Name, Password, LastSignedIn, CreatedDate, City, Country, /*etc*/}
換句話說:我應該正常化的NoSQL文件?
你可以請指教嗎?
在我的特殊情況下,我正在用mongoose使用mongodb。
剛剛更新了問題。我正在用'mongoose'使用'mongodb' – sreginogemoh
然後,正如我在很多情況下所說的那樣,最好只有一個大集合。當然,也有例外,它取決於關係的基數(將兩個表格代表多對多關係可能導致組合爆炸...) – RafaelCaballero
所以如果我有'document'和它的'subdocuments'我可以說檢索特定的'subdocument'或者用'findqueries'跳過另一個?例如:'Account.findOne({name:'user'},包括:{'subdoc1'})' - 所以它將包含'subdoc1'的任何內容,並且不會在結果中包含任何其他子文檔 – sreginogemoh