NoSQL Databases: Document, Key-Value, Wide-Column and Graph Interview Questions
261 multiple-choice tech interview questions on NoSQL Databases: Document, Key-Value, Wide-Column and Graph: document, key-value, wide-column and graph models, partition keys, schema design, choosing SQL or NoSQL. Written for technical phone screens and interview prep, organized by subtopic, with a short explanation for every answer. Learn the 244 key terms with the flashcards first, then test yourself.
Take the practice test · Flashcards · All study tools
What it covers
- 5.1 NoSQL models and their trade-offs
- 5.2 Document modeling with MongoDB
- 5.3 MongoDB queries, indexes and operations
- 5.4 DynamoDB keys, indexes and single-table design
- 5.5 DynamoDB capacity, streams and operations
- 5.6 Azure Cosmos DB
- 5.7 Wide-column stores: Cassandra, ScyllaDB and Bigtable
- 5.8 Graph, time-series and search stores
- 5.9 Partitioning, consistency and choosing a NoSQL store
Key terms
5.1 NoSQL models and their trade-offs
- Document store
- A database storing semi-structured JSON-like documents, such as MongoDB or Cosmos DB
- Key-value store
- A database that stores opaque values looked up by key, such as Redis or DynamoDB
- Wide-column store
- A database organizing rows by partition key with flexible columns, such as Cassandra
- Graph database
- A database storing nodes and relationships for fast traversals, such as Neo4j
- NoSQL
- Not only SQL
- NoSQL origins
- Web scale
- Dynamo paper
- 2007
- Bigtable paper
- 2006
- Document strength
- Nested aggregates
- Key-value limit
- Key lookups only
- Wide-column layout
- Partitions and sorted columns
- Graph data
- Nodes and relationships
- Index-free adjacency
- Direct neighbor pointers
- Property graph vs RDF
- Properties vs triples
- Schemaless myth
- Implicit schema
- NewSQL
- Distributed ACID SQL
- RocksDB
- Embedded LSM engine
- Wide-column vs columnar
- Not the same
- Amazon QLDB
- Ended 2025
- Search as source of truth
- Avoid
- GQL
- ISO graph language
- Scale-out writes
- Partition by key
- Varied attributes
- Documents
- Document weakness
- Cross-document joins
- Managed document stores
- Atlas, DocumentDB, Firestore
5.2 Document modeling with MongoDB
- Partition key
- The attribute that decides which partition stores an item and spreads load
- Hot partition
- A partition receiving a disproportionate share of traffic and being throttled
- Request unit (RU)
- Cosmos DB's normalized cost of a database operation
- BSON
- Binary typed JSON
- ObjectId
- Timestamp, random, counter
- _id
- Unique key
- One-to-squillions
- Parent reference
- Extended reference
- Copy key fields
- Subset pattern
- Embed most-used
- Bucket pattern
- Group readings
- Computed pattern
- Precompute on write
- Outlier pattern
- Overflow documents
- Polymorphic pattern
- Shapes in one collection
- Attribute pattern
- Key-value array
- $jsonSchema
- Validation rules
- validationAction warn
- Log, allow
- Query-driven design
- Model for access
- Many-to-many in MongoDB
- ID arrays
- Single-document atomicity
- No transaction needed
- Short field names
- Stored per document
- BSON Date
- Sortable dates
- Decimal128
- Exact money
- Large documents
- More I/O
- Ancestor array
- Tree queries
- Mongoose
- Node.js ODM
- Time series collections
- Bucketed storage
- Capped collection
- Fixed size
- Dynamic field names
- Avoid
5.3 MongoDB queries, indexes and operations
- $gt
- Greater than
- Projection
- Choose fields
- $elemMatch
- Same element
- Dot notation
- Nested fields
- $set
- Change fields
- $inc
- Atomic increment
- $push with $slice
- Capped array
- Upsert
- Insert if missing
- Aggregation pipeline
- Stages
- $match early
- Filter first
- $lookup
- Left outer join
- $unwind
- One per element
- ESR rule
- Equality, Sort, Range
- Multikey index
- Array index
- TTL index
- Auto-expire
- explain
- IXSCAN vs COLLSCAN
- Atlas Search
- Lucene search
- Replica set
- Primary and secondaries
- secondaryPreferred
- Possibly stale reads
- Read concern majority
- Won't roll back
- mongos
- Query router
- Config servers
- Cluster metadata
- Hashed shard key
- Even inserts
- Resharding
- Change shard key
- Transaction lifetime
- 60 seconds
- Change streams
- Change feed
- Retryable writes
- Safe retry
- WiredTiger
- Storage engine
5.4 DynamoDB keys, indexes and single-table design
- Primary key types
- Partition or composite
- Item size
- 400 KB
- LSI
- Same PK, new SK
- LSI limit
- 10 GB per collection
- GSI consistency
- Eventual only
- GSI projection
- Copied attributes
- Sparse GSI
- Only items with the key
- Query vs Scan
- Partition vs table
- Filter expressions
- Paid after read
- begins_with
- Sort key prefix
- Item collection
- Same partition key
- Adjacency list pattern
- Inverted GSI
- Access patterns first
- List them up front
- Hierarchical sort key
- Prefix queries
- LastEvaluatedKey
- Pagination
- 1 MB page
- Before filters
- ScanIndexForward
- Reverse order
- Counting items
- Counter item
- Number precision
- 38 digits
- BatchGetItem
- 100 items
- UnprocessedKeys
- Retry with backoff
- ProjectionExpression
- No capacity savings
- GSI write cost
- Extra writes
- GSI quota
- 20 per table
- Single-table drawback
- Harder to evolve
- PartiQL
- SQL-like access
5.5 DynamoDB capacity, streams and operations
- Capacity modes
- On-demand or provisioned
- RCU
- 4 KB strong read
- Eventual reads
- Half cost
- WCU
- 1 KB write
- Transactional cost
- Double
- Throttling
- Retry with backoff
- On-demand price cut
- November 2024
- Auto scaling
- Target utilization
- Partition limits
- 3,000 RCU, 1,000 WCU
- Adaptive capacity
- Shifts to hot partitions
- DynamoDB Streams
- 24-hour change log
- NEW_AND_OLD_IMAGES
- Before and after
- Lambda trigger
- Stream processing
- Kinesis for DynamoDB
- Longer retention
- TTL
- Free background deletes
- TTL lag
- Filter expired
- attribute_not_exists
- Insert if new
- Unique attribute
- Guard item in transaction
- ClientRequestToken
- Idempotent transaction
- Global tables
- Multi-active regions
- MRSC
- Strong multi-region
- Export to S3
- No capacity used
- Zero-ETL
- Synced copies
- Standard-IA
- Cheap storage
- Contributor Insights
- Hot keys
- Warm throughput
- Pre-warm
- Encryption at rest
- Always on
- LeadingKeys
- Per-user items
- Deletion protection
- Guard table
5.6 Azure Cosmos DB
- Session default
- Cosmos DB
- Point read
- About 1 RU
- 429
- Too many requests
- Logical partition limit
- 20 GB
- Logical vs physical
- Many to one
- Physical partition limit
- 10,000 RU/s
- Hierarchical partition keys
- Up to three levels
- Synthetic key
- Combined properties
- Default indexing
- Everything
- Excluded paths
- Cheaper writes
- Composite index
- Multi-property ORDER BY
- Change feed
- Ordered changes
- Change feed deletes
- Soft delete or AVAD
- Cosmos TTL
- Auto-expire
- Multi-region writes
- Write anywhere
- Serverless
- Per-RU billing
- Autoscale
- 10% to 100%
- Free tier
- 1,000 RU/s, 25 GB
- Transactional batch
- One logical partition
- Integrated cache
- 0-RU repeat reads
- Partition key change
- New container
- Request charge
- RU per request
- Fabric mirroring
- Analytics copy
- Relaxed consistency
- Per request
- Continuous backup
- 7 or 30 days
5.7 Wide-column stores: Cassandra, ScyllaDB and Bigtable
- Partition key and clustering
- Cassandra primary key
- Clustering order
- Sorted within partition
- Table per query
- Duplicate data
- ALLOW FILTERING
- Possible scan
- Bounded partitions
- Keep them small
- Time bucket
- Limit growth
- Tombstone
- Delete marker
- Tombstone pileup
- Slow reads
- Write path
- Commit log, memtable, SSTable
- TWCS
- Time-series compaction
- UCS
- Cassandra 5.0 compaction
- SAI
- Secondary indexes
- Lightweight transaction
- Paxos
- Gossip
- Peer state
- NetworkTopologyStrategy
- Replicas per DC
- LOCAL_QUORUM
- Local DC majority
- Hinted handoff
- Replay later
- Repair
- Anti-entropy
- Counter columns
- Not idempotent
- Logged batch
- Multi-table sync
- Upsert semantics
- Overwrite
- ScyllaDB
- C++ Cassandra
- Amazon Keyspaces
- Managed Cassandra
- Bigtable row key
- Only index
- HBase
- HDFS and ZooKeeper
- Materialized views
- Experimental
- No joins
- CQL
- Token-aware driver
- Direct to replica
5.8 Graph, time-series and search stores
- MERGE
- Create if missing
- Variable-length path
- *1..3
- shortestPath
- Shortest connection
- Gremlin
- TinkerPop traversals
- Amazon Neptune
- Managed graph
- Supernode
- Huge degree
- Graph algorithms
- PageRank, communities
- Labels
- Node tags
- Relationship direction
- Always stored
- Apache AGE
- Cypher in PostgreSQL
- Hypertable
- Time chunks
- Continuous aggregates
- Incremental rollups
- Line protocol
- Measurement, tags, fields
- Tags vs fields
- Indexed vs values
- InfluxDB 3
- Arrow and Parquet
- Append-optimized
- Time-ordered writes
- Time-series compression
- Deltas
- Azure Data Explorer
- KQL analytics
- Analyzer
- Tokenize and normalize
- text vs keyword
- Analyzed vs exact
- Refresh interval
- Near real-time
- Primary shard count
- Fixed
- search_after
- Deep paging
- Elastic AGPL
- 2024
- OpenSearch Foundation
- Linux Foundation
- Redis 8 JSON and query
- Built in
- OPTIONAL MATCH
- Outer join
- Uniqueness constraint
- No duplicate nodes
5.9 Partitioning, consistency and choosing a NoSQL store
- Eventual consistency
- Replicas converge if writes stop, but reads may be stale until then
- Polyglot persistence
- Using different databases for different needs in one system
- Orders partition key
- Customer ID
- Async global indexes
- Faster writes
- Local vs global indexes
- Partition vs value
- JSONB instead
- Joins and transactions
- Request-unit costs
- Scans cost
- Lazy migration
- Upgrade on touch
- Continuation tokens
- Resume pages
- Emulators
- Local tests
- YCSB
- NoSQL benchmark
- Realistic key skew
- Find hot partitions
- Document vs graph
- Multi-hop links
- Search sync
- Change feed
- Scan guardrails
- Permissions and alerts
- Lock-in
- Hard to port
- Compatible APIs
- Test features
- Sharded counters
- Firestore writes
- Firestore offline
- Local cache sync
- Security rules
- Firestore access
- Couchbase
- Document store with cache
- SSPL
- MongoDB license
- Per-user partitions
- Fast erasure
- Small items
- Lower cost
- Normalized email key
- Case-insensitive
- Scan order
- Not guaranteed
- Version items
- v0 latest
Sample practice questions
Which database is a document store?
- Redis
- Apache Cassandra
- MongoDB
- Neo4j
Answer: C. MongoDB MongoDB stores JSON-like BSON documents. Redis is key-value, Cassandra is wide-column and Neo4j is a graph database.
In document modeling, when should you embed related data rather than reference it?
- When it grows without limit, such as every click a user ever makes
- When it's read together, owned by one parent and bounded, like order lines
- When many parents share the same item and that item changes often
- Always; references are never used in document database models
Answer: B. When it's read together, owned by one parent and bounded, like order lines Embed for one-to-few data read together. Reference for unbounded, shared or independently updated data.
Which statement about modern NoSQL transaction support is accurate?
- No NoSQL database supports transactions of any kind, even on a single document
- Every NoSQL database supports unlimited cross-region ACID transactions by default
- MongoDB has multi-document ACID; DynamoDB's TransactWriteItems spans up to 100 items
- Only graph databases support transactions; document and key-value stores never do
Answer: C. MongoDB has multi-document ACID; DynamoDB's TransactWriteItems spans up to 100 items Transactions exist but have limits and costs; designs still try to keep related writes in one item or partition.
In DynamoDB, what does a sort key enable?
- Sorting the entire table globally by any attribute you choose at query time
- Joining two DynamoDB tables together on matching key attributes
- Encrypting each item with a key derived from its sort attribute
- Many sorted items per partition key, with range queries like date ranges
Answer: D. Many sorted items per partition key, with range queries like date ranges Partition key plus sort key form the primary key. Query reads one partition key's items, optionally filtered by sort key range.
What are DynamoDB's two capacity modes?
- On-demand, billed per request, and provisioned, with set read and write units
- Serverless and dedicated, depending on the instance size
- Hot and cold, depending on how often the table is read
- Single-region and global, depending on replication
Answer: A. On-demand, billed per request, and provisioned, with set read and write units You can switch modes on an existing table.
Azure Cosmos DB is best described as
- a relational data warehouse for large analytical queries only
- a managed file share service mounted over SMB by VMs
- an in-memory cache service for session and lookup data only
- a globally distributed, multi-model database with several APIs
Answer: D. a globally distributed, multi-model database with several APIs Cosmos DB also offers vector search and a PostgreSQL option (Cosmos DB for PostgreSQL, built on Citus).
In Cassandra, why must queries usually include the partition key?
- Cassandra requires every query to be written as a join
- Data is spread by partition key; without it every node is scanned
- The partition key is also used to authenticate the caller
- Without it, results come back quickly but are unsorted
Answer: B. Data is spread by partition key; without it every node is scanned Cassandra tables are designed per query. ALLOW FILTERING exists but is an anti-pattern at scale.
What does Cypher, used by Neo4j, look like for "Alice's friends"?
- `MATCH (a:Person {name:'Alice'})-[:FRIEND]->(f) RETURN f`
- `SELECT f.* FROM Person a JOIN FRIEND f ON a.name = 'Alice'`
- `g.V().has('Person','name','Alice').out('FRIEND').values()`
- `db.people.find({ name: 'Alice' }, { friends: 1, _id: 0 })`
Answer: A. `MATCH (a:Person {name:'Alice'})-[:FRIEND]->(f) RETURN f` Cypher uses ASCII-art patterns: nodes in parentheses and relationships in brackets with arrows. The other options are SQL, Gremlin and the MongoDB shell.
In DynamoDB or Cosmos DB, why does choosing a good partition key matter so much?
- It determines the order in which fields are stored inside each document
- It decides which users and roles are allowed to read the data
- It spreads data and load evenly and lets common queries hit one partition
- It controls how often the database takes automatic backups
Answer: C. It spreads data and load evenly and lets common queries hit one partition A low-cardinality or skewed key creates "hot partitions" that throttle while others sit idle.
Which kind of database best fits "find friends of friends who like the same band" queries?
- A key-value store such as Redis
- A wide-column store such as Cassandra
- A graph database such as Neo4j
- A columnar data warehouse
Answer: C. A graph database such as Neo4j Graph databases store relationships as first-class edges, so multi-hop traversals are fast.
More Storage and Data
- Relational Database Design and Normalization
- SQL Queries, Joins and Window Functions
- Indexing and Query Optimization
- Transactions, ACID and Isolation Levels
- Caching: Redis, CDNs and Cache Invalidation
- ORMs: Entity Framework Core and Hibernate
- Data Warehousing and ETL
- Message Queues and Event Streaming: Kafka, RabbitMQ and Service Bus
- Blob and Object Storage
- Backups, Replication and Disaster Recovery