We'lllookathowtheyworkfrom a technicalperspective, butmostimportantly, we'lltrytounderstandwhatthey'rebestusedfor, becausemydadalsousedtotellme, don't bring a knifeto a gunfight.
A popularusecaseisforscaling a largeamountoftimeseriesdata, likerecordsfromanIoTdevice, weathersensors, orinthecaseofNetflix, a historyofthedifferentshowsyou'vewatched.
Forthat, you'llneedsomethingmoregeneralpurpose, like a document-orienteddatabase.
為此,你需要一些更通用的東西,比如面向文檔的數據庫。
PopularoptionsintheFirestore, DynamoDB, CouchDB, and a fewothers.
流行的選項包括 Firestore、DynamoDB、CouchDB 和其他一些選項。
Inthisparadigm, youhavedocuments, whereeachdocumentis a containerforkey-valuepairs.
在這種模式下,你有文檔,每個文檔都是鍵值對的容器。
They'reunstructuredanddon't require a schema.
它們是非結構化的,不需要模式。
Thenthedocumentsaregroupedtogetherincollections.
然後,這些文件被歸類為文件集。
Fieldswithin a collectioncanbeindexed, andcollectionscanbeorganizedinto a logicalhierarchy, allowingyoutomodelandretrieverelationaldatato a prettysignificantdegree.
Ifyou'renotexactlysurehowyourdataisstructuredatthispoint, a documentdatabaseisprobablythebestplacetostart.
如果你現在還不確定數據的結構,那麼文檔數據庫可能是最好的起點。
Wheretheygenerallyfallshortiswhenyouhave a lotofdisconnectedbutrelateddatathatisupdatedoften, like a socialappthathasmanyuserswhohavemanyfriendswhohavemanycommentswhohavemanylikes, andyouwanttoseeallthecommentsthatyourfriendslike.
However, a potentialdrawbackhereisthatitrequires a schema.
不過,它的一個潛在缺點是需要一個模式。
Ifyoudon't knowtherightdatashapeupfront, theycanbe a littlehardertoworkwith.
如果你不知道正確的數據形狀,它們可能會有點難用。
SQLdatabasesarealsoACIDcompliant, whichmeanswheneverthere's a transactioninthedatabase, datavalidityisguaranteedeveniftherearenetworkorhardwarefailures.
When a userperforms a search, itonlyhastoscantheindexasopposedtoeverydocumentinthedatabase, andthatmakesitveryfastevenonlargedatasets.
當用戶執行搜索時,只需掃描索引,而不是數據庫中的每個文檔,是以即使在大型數據集上也能非常快速。
Thedatabasecanalsorun a varietyofdifferentalgorithmstorankthoseresults, filteroutirrelevanthits, handletypos, andsoon.
數據庫還可以運行各種不同的算法,對這些結果進行排序,過濾掉不相關的點擊,處理錯別字等。
Thisdoesadd a lotofoverhead, andtheycanbeexpensivetorunatscale, butatthesametime, theycanadd a tonofvaluetotheuserexperienceifyou'rebuildingsomethinglike a type-aheadsearchbox.