CompTIA Tech+ (FC0-U71)Data and Database FundamentalsMedium
A development team wants to store shopping cart data as simple pairs, such as 'cartID123' mapped directly to a block of item data, with extremely fast lookups by that identifier and no need for complex queries. Which type of database best fits this need?
- ADocument database
- BKey-value database
- CRelational database
- DGraph database
Show answer & explanationAnswer & explanation
Correct answer: B. Key-value database
A key-value database stores data as simple key-value pairs, allowing extremely fast retrieval when the key is known, which fits this scenario perfectly. Relational databases use structured tables with relationships, document databases store flexible JSON-like documents, and graph databases model complex relationships between entities.
Why the other options are wrong
- A. Document databases store structured documents, which is more complex than needed here.
- C. Relational databases use structured tables and are less optimal for simple fast key lookups.
- D. Graph databases focus on modeling relationships between nodes, not simple lookups.
Key-Value NoSQL Database
A type of non-relational database that stores data as simple key-value pairs, optimized for extremely fast lookups by a unique key.
- Each key maps to one value or data block
- Examples include Redis and Amazon DynamoDB
- Ideal for caching, session storage, and shopping carts
Memory trick: Key-value is a locker 🗝️ — one key opens one box, instantly.