Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

164 total results found

Single Collection Pattern

MongoDB Advanced Schema Design Patterns

The single collection pattern groups related documents of different types into a single collection use case: many to many relationships one to many relationship catalog of product items shopping carts variant1: books, users, reviews docType field and rel...

Subset Pattern

MongoDB Advanced Schema Design Patterns

a book have N reviews only embed 3 reviews to the book Code Summary: Subset Pattern To apply the Subset pattern to the documents in our bookstore app, we ran the following aggregation pipeline: use("bookstore"); const copyReviews = [ { // TODO: Specify...

Bucket Pattern

MongoDB Advanced Schema Design Patterns

The bucket pattern: groups pieces of information into buckets keep documents size predictable read only data we need reduce number of documents in a collection improve index performance Example: track user views per book each view needs: user_id, book_id, t...

Outlier Pattern

MongoDB Advanced Schema Design Patterns

used when some documents are different and needs a different method to interact. example: most of books have a single digit reviews, so embeded method is used. but one or two hot sales have lots of reviews, so reference method needs to be used. Code Summary: O...

Archive Pattern

MongoDB Advanced Schema Design Patterns

Move data no longer needed to a different place so performance is not dragged. archive book reviews that are more than one year old

Anti Patterns

MongoDB Schema Design Anti Patterns

Unbounded Arrays an array without a size limit used subset pattern or extended reference pattern Bloated Docments A document that groups together related data that is accessed separately say a book store has two pages: home and detailed page. Home shows 10 ...

Schema Validation

MongoDB Schema Lifecycle Management

To create a new "sales" collection schema validation, we use the createCollection method with the validator option. In this example, we combine a query operator, $and, and JSON schema to define the schema validation rules. $and checks the discounterPrice is lo...

Schema Evolution

MongoDB Schema Lifecycle Management

In this example, we implemented the updated reviews schema to include an optional locale field, in the properties document, which accepts only fr or en values: const bookstore_reviews_international = { bsonType: "object", required: [“_id”, "review_id",...

Schema Migration

MongoDB Schema Lifecycle Management

Schema migration is transition from one schema to the next Migration Strategies: Eager: all at once Lazy: as data is used Incremental: small interactive steps Predictive: updates the schema based on predictions for future data usage Here’s the default schema...

MongoDB Cheatsheet

Cheat Sheets Database

Feature easy to use, well documented similar to SQL B-Tree ACID Transactions Single Leader Replication Supports $lookup operation, which is basically a left outer join since it's also using B-Tree, indexing is similar to relational SQL Flexible Schema ...

Regex

Cheat Sheets Fundamentals

// Character class [xyz] => matches one of [x,y,z] [a-c] => matches one of [a,b,c] // Negated character class [^xyz] => matches anything that is not in [x,y,z] [^a-c] => matches anything that is not in [a,b,c] // Wildcard . => matches any single character ex...

Redis Cheatsheet

Cheat Sheets Database

Key Points in-memory, key-value store supports string, int, hash(map<string, string>), list, set, sorted set, bitmap can be used as a database, cache, messsage broker, pub/sub key-eviction, expiration, hashes, string, set, order-set, pub/sub, channel, RDB, AO...

Fundamentals and High Level Overview

Cheat Sheets System Design

System Design Process Gather requirments Back of envelope calculations API design Architectual design 1 Database sequential reads and writes are always cheaper than random reads and writes want to keep data that is frequently read together close together w...

Trees

Cheat Sheets DSA

Types of trees Binary Tree Binary Search Tree left child < node < right value AVL Tree self balanced BST diff(height(leftChild), height(rightChild)) <= 1 Red-Black Tree solves the same problem as AVL Tree but with less strict balance and thus less ...

Nginx Cheatsheet

Cheat Sheets

Configuration files /etc/nginx/nginx.conf /etc/nginx/sites-available/* /etc/nginx/sites-enabled/* Master and worker processes master process reads and evaluate configurations, and maintain worker processes. worker processes process the actual requests...

Message Broker / Stream Processing Cheatsheet

Cheat Sheets

Stream Processing a broker between producers and consumers broker deals with TCP/UDP connections, processing speed, etc.. In memory vs Log based (on disk) if order doesn't matter, and no need to persistent data, then use in-memory message broker if order ...

Git

Cheat Sheets Fundamentals

Dev developing procedure checkout a new branch called "feature_branch" make modifications commit, push pull main, update to latest merge main to feature_branch with git rebase main resolve conflicts and commit push feature_branch to remote with git push -f o...

Setting up a Redis-Cluster in Kubernetes

Cheat Sheets Configuration Notes

Definitions

Cheat Sheets DSA

Bloom Filter Searching for a key in a cache system might take a long time in a LSM tree because it would require to look through all SSTables before finally realizing the key doesn't exists Bloom filter uses multiple different hash values to determine if the ...

Strings

Cheat Sheets DSA

ZList: def buildZList(s: str) -> List[int]: """ Used in pattern matching: buildZList(needle + '.' + haystack) and check for length(needle) in result Construct an array of length equal to the length of the input string Where the first number in...