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.
Inthisparadigm, youhavedocuments, whereeachdocumentis a containerforkey-valuepairs.
They'reunstructuredanddon't require a schema.
Thenthedocumentsaregroupedtogetherincollections.
Fieldswithin a collectioncanbeindexed, andcollectionscanbeorganizedinto a logicalhierarchy, allowingyoutomodelandretrieverelationaldatato a prettysignificantdegree.
Theydon't supportjoins, soinsteadofnormalizingyourdatainto a bunchofsmallparts, you'reencouragedtoembedthedocument.
Thiscreates a tradeoffwherereadsfrom a friendandapplicationaremuchfaster, howeverwritingorupdatingdatatendstobemorecomplex.
Ifyou'renotexactlysurehowyourdataisstructuredatthispoint, a documentdatabaseisprobablythebestplacetostart.
Wheretheygenerallyfallshortiswhenyouhave a lotofdisconnectedbutrelateddatathatisupdatedoften, like a socialappthathasmanyuserswhohavemanyfriendswhohavemanycommentswhohavemanylikes, andyouwanttoseeallthecommentsthatyourfriendslike.
Datalikethisneedstobejoined, andit's noteasilydonein a documentdatabaseatscale.
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.