1. Home
  2. Explore
  3. Computer Science
  4. Database Selection in System Design

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Database Selection in System Design

  • 46Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Database Selection

How does database choice generally affect functional and non-functional requirements in a system design?

46 questions

  1. 1

    How does database choice generally affect functional and non-functional requirements in a system design?

    Model answer

    A database choice usually does not determine whether functional requirements can be met, but it can strongly affect how well the system meets non-functional requirements such as scalability.

    Explanation

    Different databases are optimized for different data structures, query patterns, and scales, so the choice affects how effectively the design can meet its non-functional requirements.

  2. 2

    What three factors should guide the choice of a database?

    Model answer

    Consider the structure of the data, the query patterns, and the scale the system must handle.

    Explanation

    These factors influence which database’s capabilities and optimizations best fit the use case.

  3. 3

    Why might two databases that both meet an application's functional needs differ in suitability?

    Model answer

    They may handle the application's data structure, queries, or required scale with different levels of effectiveness.

    Explanation

    Database selection is often driven by non-functional needs, because database technologies are optimized for different workloads.

  4. 4

    When the data is structured and the application needs complex transactions, what broad category of database is generally appropriate?

    Model answer

    A relational database is generally appropriate when structured data requires transactional guarantees.

    Explanation

    Relational databases model structured information in tables and commonly provide ACID guarantees.

  5. 5

    If a system has a small dataset, few attributes, few query types, and none of the specialized requirements discussed, what database choice is reasonable?

    Model answer

    Any suitable database may be reasonable, since the system has no special workload requirements that dictate a particular type.

    Explanation

    The content characterizes this as a low-scale case with a small dataset and few queries, where many database choices can work.

  6. 6

    Why should a database recommendation from a system design interview be treated as a starting point rather than a complete real-world evaluation?

    Model answer

    It is an indicative guide; a real deployment requires further research to choose the specific database that best fits the system.

    Explanation

    The discussed databases are examples rather than the only available options, and actual use requires more detailed evaluation.

  7. 7

    How does a cache reduce repeated work when an application queries a database?

    Model answer

    It stores a previously obtained value so that a later request can use the cached value instead of querying the database again.

    Explanation

    Caching can reduce the number of repeated database queries.

  8. 8

    Why might an application cache the response from a remote service locally?

    Model answer

    Caching the response locally can avoid repeated remote calls when those calls have high latency.

    Explanation

    A cache can store the response from another system for subsequent use.

  9. 9

    What are the key and value in a typical key-value cache?

    Model answer

    The key is commonly based on the query condition or request parameters, and the value is the response expected from the database or other system.

    Explanation

    The key identifies the cached result, while the value stores that result.

  10. 10

    Name several caching solutions and identify the one used as the main example in the content.

    Model answer

    Examples include Redis, Memcached, etcd, and Hazelcast; Redis is used as the main example.

    Explanation

    The content describes Redis as a battle-tested, stable option, while noting that similar solutions can also be used.

  11. 11

    Why are images and videos commonly stored in blob storage rather than treated as ordinary database records?

    Model answer

    Blob storage is designed to store and serve files as-is, whereas databases are fundamentally intended for data that can be queried.

    Explanation

    Images and videos are file content that is generally served rather than queried like structured records.

  12. 12

    How can Amazon S3 and a content delivery network work together to serve images or videos?

    Model answer

    S3 can act as the primary blob store, while a CDN distributes copies across geographically separated servers to serve users faster.

    Explanation

    Serving content from locations nearer to users can be faster than retrieving it from a primary store located in only a few places.

  13. 13

    What kinds of applications commonly need blob storage?

    Model answer

    Applications that store and serve files such as product images, product videos, or streaming video content commonly need blob storage.

    Explanation

    Examples include an e-commerce catalog with seller-uploaded media and a video service.

  14. 14

    What technologies are commonly used to provide text-search capabilities, and what library underlies them?

    Model answer

    Elasticsearch and Solr are common text-search engines, and both are built on Apache Lucene.

    Explanation

    Lucene provides text-search capabilities that are used by Elasticsearch and Solr.

  15. 15

    Give examples of application features that can use a text-search engine.

    Model answer

    Examples include searching product titles and descriptions, movie titles, genres, cast and crew, or locations with fuzzy matching.

    Explanation

    These use cases require searching text across varied fields, and some also benefit from fuzzy search.

  16. 16

    What is fuzzy search, and why can it improve a search experience?

    Model answer

    Fuzzy search can return relevant results when a query contains a spelling error, avoiding an empty result when the intended term is recognizable.

    Explanation

    For example, a search engine may recognize a misspelled query as an attempt to search for the correctly spelled word.

  17. 17

    In the example where “AIRPROT” is intended to be “AIRPORT,” what edit distance is given, and what does it represent?

    Model answer

    The example gives an edit distance of two: the two letters are interchanged through two character changes.

    Explanation

    The content uses this example to illustrate a fuzziness factor; edit distance roughly represents the number of character changes needed to reach the intended spelling.

  18. 18

    Why should Elasticsearch or Solr generally not be the primary source of truth for an application's data?

    Model answer

    They are search engines, not databases that guarantee data will not be lost, so the primary data should be stored elsewhere and loaded into them for searching.

    Explanation

    Although they provide availability and redundancy, the content warns that data could potentially be lost in these systems.

  19. 19

    What is a time-series database, and what workload is it designed to support?

    Model answer

    It is a database suited to timestamped data written sequentially in append-only fashion and read in bulk over time ranges.

    Explanation

    Metrics systems commonly write new observations over time and query recent minutes, hours, or days rather than performing random updates.

  20. 20

    How do the typical write and read patterns for metrics differ from random database access?

    Model answer

    Metrics are generally appended in chronological order, while reads retrieve batches of records over a time range; random updates and reads are not typical.

    Explanation

    A record at a later time follows earlier records, and queries often request a span such as the last few hours or days.

  21. 21

    What kinds of data and applications are suited to a time-series database?

    Model answer

    Timestamped metrics such as throughput, CPU utilization, and latency from monitoring systems are suited to a time-series database.

    Explanation

    Systems such as application-metrics platforms collect these measurements over time.

  22. 22

    Name two time-series database options from the content.

    Model answer

    InfluxDB and OpenTSDB are examples of time-series databases.

    Explanation

    Both are presented as options for workloads involving sequential metric writes and time-range reads.

  23. 23

    What is a data warehouse used for, and how does its use differ from that of a transactional database?

    Model answer

    A data warehouse consolidates large amounts of company data for analytics and reporting, generally serving offline reporting rather than transactions.

    Explanation

    It supports queries and reports such as order counts, revenue by geography, and popular items.

  24. 24

    How can Hadoop be used in an analytics architecture?

    Model answer

    Data from multiple transactional systems can be placed in Hadoop, with reporting systems built on top of that data.

    Explanation

    The content presents Hadoop as an option for a data-warehouse-style offline analytics purpose.

  25. 25

    What makes data structured, and what is one example?

    Model answer

    Structured data can be readily modeled as tables with rows and columns; a user profile with fields such as name, email, city, and phone number is an example.

    Explanation

    The example has a standard set of fields for each user, making it suitable for a tabular representation.

  26. 26

    What is the central transactional requirement when transferring money between two accounts?

    Model answer

    The debit from one account and the credit to the other must succeed together or both fail.

    Explanation

    The database must prevent a partial transfer in which money is debited without being credited, or vice versa.

  27. 27

    What consistency behavior is expected after a successful transaction in the payment example?

    Model answer

    A subsequent balance query should reflect the transaction consistently, rather than sometimes returning an outdated or incorrect balance.

    Explanation

    The content describes consistency as ensuring that the next read reflects the completed transaction.

  28. 28

    Why are relational databases appropriate for payment or inventory systems that require atomicity and consistency?

    Model answer

    They can provide transactional guarantees that keep related updates together and maintain consistent results.

    Explanation

    Payment transfers and inventory decrements must not be left in partially completed states.

  29. 29

    How does the inventory example illustrate the need for transactional guarantees?

    Model answer

    When customers buy products, the inventory count must be reduced correctly so that purchases do not leave the stock count inconsistent.

    Explanation

    Inventory management is given as a use case for atomicity, consistency, and transactions.

  30. 30

    Name common relational database systems listed in the content.

    Model answer

    MySQL, Oracle, SQL Server, and PostgreSQL are listed examples.

    Explanation

    They are examples of relational databases; other options can also be used if they meet the system's needs.

  31. 31

    If data is structured but the application does not require ACID guarantees, must it use a relational database?

    Model answer

    No. It may use a relational database or a non-relational database, since structured data can often be mapped into a NoSQL model.

    Explanation

    The content says either choice can work when structured data does not require transactional guarantees.

  32. 32

    What is a document database suited to when data has many varied attributes and queries?

    Model answer

    It is suited to data with many possible attributes and a wide variety of queries, especially when those attributes are difficult to model or query conveniently in relational tables.

    Explanation

    A product catalog may contain different attributes for shirts, refrigerators, and groceries, and users may need to query those attributes.

  33. 33

    Why can storing varied product attributes as JSON be insufficient for an e-commerce catalog?

    Model answer

    Although the JSON can be stored, querying on its varied or arbitrary attributes can be difficult with a relational database.

    Explanation

    Catalog users often need to search or filter by attributes, not merely retrieve the stored data.

  34. 34

    Give examples of how the attributes of a shirt, refrigerator, and milk product can differ in a catalog.

    Model answer

    A shirt may have size and color, a refrigerator may have volume and energy-rating attributes, and milk may have quantity and expiry date.

    Explanation

    These examples illustrate why items in the same catalog can have different sets of attributes.

  35. 35

    Name two document databases mentioned in the content.

    Model answer

    MongoDB and Couchbase are examples.

    Explanation

    They are presented as options for data with varied structures and query needs.

  36. 36

    How are Elasticsearch and Solr related to document databases in the content?

    Model answer

    They are described as special cases of document databases, while also serving specifically as text-search engines.

    Explanation

    Their primary role in the discussion is to provide efficient text searching.

  37. 37

    What pattern defines the “ever-increasing data” example involving ride-share driver locations?

    Model answer

    Drivers continually send location records, and the number of records grows as the number of drivers increases.

    Explanation

    The content illustrates growth with an increasing number of daily location pings rather than a fixed volume.

  38. 38

    What workload characteristics make a column-oriented database a good fit for driver location pings?

    Model answer

    A large, continually growing dataset with a limited number of query types—such as retrieving locations for a given driver—is a good fit.

    Explanation

    The volume may be high, but the application has a relatively small set of predictable queries.

  39. 39

    Name two column-oriented database options and describe how the content compares their deployment and performance.

    Model answer

    Cassandra and HBase are options; the content describes their performance as roughly similar but says HBase tends to bring more deployment components.

    Explanation

    Cassandra is preferred in the speaker's examples because it is described as less heavy to deploy, while both are characterized as stable options.

  40. 40

    What is the distinction between a relational database and a column-oriented database in the examples?

    Model answer

    The relational database is recommended for structured data requiring transactional guarantees, while the column-oriented database is recommended for large, growing data with a limited set of queries.

    Explanation

    The content uses payments and inventory for relational workloads and driver location pings for column-oriented workloads.

  41. 41

    Why might an e-commerce inventory system use a relational database even if the company's order history is continually growing?

    Model answer

    Inventory updates need transactional guarantees to prevent overselling, while the growing order history has a different storage need.

    Explanation

    When only one item remains, concurrent purchases must not both commit as if the item were available.

  42. 42

    How can an e-commerce system combine a relational database and Cassandra for orders?

    Model answer

    It can keep orders that have been placed but not yet delivered in a relational database, then move delivered orders to Cassandra as a permanent store.

    Explanation

    This approach combines transactional handling of current orders with storage for an ever-growing order history.

  43. 43

    Why might a reporting feature that searches orders by different products or product qualities need a document database in addition to order databases?

    Model answer

    A document database can store query-oriented order information that supports varied searches across products, while the main order records remain in the relational and/or Cassandra stores.

    Explanation

    Searching for users who bought broad categories or particular product qualities involves flexible queries across many item identifiers.

  44. 44

    What kind of subset of order information could be placed in MongoDB to support product-based reporting?

    Model answer

    A record could include a user ID, order ID, date, and the item IDs and quantities in the order.

    Explanation

    A query on this subset can return users and order IDs; the order IDs can then be used to look up fuller records in the other stores.

  45. 45

    Describe the query flow for finding users who bought a product when order data is distributed across MongoDB, a relational database, and Cassandra.

    Model answer

    Query MongoDB for matching users and order IDs, then use those order IDs to retrieve the corresponding order records from the relational database and/or Cassandra.

    Explanation

    MongoDB provides the flexible query path, while the other databases hold order data.

  46. 46

    What does the e-commerce reporting example illustrate about database choices in real-world systems?

    Model answer

    A system may combine several database types, assigning each a role that fits different functional and non-functional requirements.

    Explanation

    The example uses relational storage, Cassandra, and a document database to support transactional, archival, and flexible reporting needs.

1 of 46
Question 1 of 46

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent