1. Home
  2. Explore
  3. Computer Science
  4. Build a Database from Scratch

Study methods

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

Build a Database from Scratch

  • 29Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Database Storage Basics
MySQL creates a
for each database within its data directory.

29 questions

  1. 1
    MySQL creates a
    _____
    for each database within its data directory.
    Hint

    Think about how files are organized on a file system.

    Answer

    folder

  2. 2
    A table file in MySQL stores both the table data and the
    _____
    for the primary key.
    Hint

    This structure speeds up searching by primary key.

    Answer

    index

  3. 3
    Using
    _____
    format for storing table data complicates random access because row boundaries must be found linearly.
    Hint

    This common data format uses delimiters like commas.

    Answer

    CSV

  4. 4
    To make rows the same size in a file, strings are forced to have a
    _____
    number of characters.
    Hint

    This ensures each string field occupies a fixed byte count.

    Answer

    maximum

  5. 5
    In the fixed-size row format, each row uses 4 bytes for the primary key, 1 byte for string length, and 255 bytes for the string, totaling
    _____
    bytes.
    Hint

    Add the three components together.

    Answer

    260

  6. 6
    Linear search through a file has time complexity
    _____
    while indexed search is O(log n).
    Hint

    Think about how time grows with the number of rows.

    Answer

    O(n)

  7. 7
    A
    _____
    index suffers from the problem of becoming a linked list if keys are inserted in ascending order.
    Hint

    This common data structure has at most two children per node.

    Answer

    binary tree

  8. 8
    In a B-Tree, each node can have more than two children, and the maximum number of keys in a node is given by the formula
    _____
    where C is the minimum number of children.
    Hint

    If C=2, max keys would be 3.

    Answer

    2C-1

  9. 9
    When a B-Tree node reaches its maximum number of keys, the
    _____
    key is moved up to the parent during insertion.
    Hint

    This key is the middle one in sorted order.

    Answer

    median

  10. 10
    When splitting a full B-Tree node, the node is divided into two nodes, and a new
    _____
    is created if the current node is the root.
    Hint

    This node has no parent.

    Answer

    root

  11. 11
    To store a B-Tree on disk, each node is stored in a single
    _____
    of data.
    Hint

    Reading from disk happens in fixed-size chunks.

    Answer

    block

  12. 12
    In a B-Tree stored on disk, children pointers are represented as
    _____
    numbers.
    Hint

    These numbers are sequential offsets into the file.

    Answer

    block

  13. 13
    The database introduces its own storage unit called a
    _____
    which may consist of one or more disk blocks.
    Hint

    It's larger than a block and its size is defined by the database.

    Answer

    page

  14. 14
    A
    _____
    page stores variable-length data by using a slot array at the beginning and cells at the end.
    Hint

    The term describes a method for efficient insertion and binary search.

    Answer

    slotted

  15. 15
    In a slotted page, each slot in the array is a 2-byte
    _____
    that points to the corresponding cell.
    Hint

    It indicates the position of the cell within the page.

    Answer

    offset

  16. 16
    In index-organized storage, tables are stored as
    _____
    sorted by the primary key.
    Hint

    This data structure is used for both the table and indexes.

    Answer

    B-Trees

  17. 17
    When a row exceeds a predefined size threshold, the database uses
    _____
    pages to store the remaining data.
    Hint

    These pages form a linked list.

    Answer

    overflow

  18. 18
    The SQL parser converts a string into an
    _____
    (AST) representing the statement.
    Hint

    This tree structure captures the syntax hierarchy.

    Answer

    Abstract Syntax Tree

  19. 19
    The
    _____
    performs context-dependent analysis like checking if a table exists or if data types match.
    Hint

    It runs after parsing to validate semantics.

    Answer

    analyzer

  20. 20
    The query plan uses the
    _____
    model, where each node is an iterator that returns one tuple at a time via .next() calls.
    Hint

    This pattern processes tuples one by one without loading all into memory.

    Answer

    iterator

  21. 21
    Picking specific columns from a row in relational algebra is called
    _____
    .
    Hint

    It reduces the number of attributes.

    Answer

    projection

  22. 22
    The
    _____
    plan collects all tuples from its source into a fixed-size memory buffer and writes to a temporary file when full.
    Hint

    This plan supports operations that need the entire dataset, like sorting.

    Answer

    collect

  23. 23
    The algorithm used for sorting large datasets that do not fit in RAM is called
    _____
    .
    Hint

    It works in passes using multiple input buffers.

    Answer

    K-Way External Merge Sort

  24. 24
    In the K-Way External Merge Sort, each pass multiplies the run size by
    _____
    .
    Hint

    With K=2, runs double each pass.

    Answer

    K

  25. 25
    The cache replacement policy used in MKDB is the
    _____
    algorithm.
    Hint

    It uses a circular array and reference bits.

    Answer

    clock

  26. 26
    In the clock algorithm, when a page is modified, its
    _____
    bit is set to 1.
    Hint

    This indicates the page needs to be written back to disk.

    Answer

    dirty

  27. 27
    To implement rollback, the database writes the original contents of pages to a
    _____
    before modifying them.
    Hint

    This file stores a copy of the original data.

    Answer

    journal file

  28. 28
    Committing a transaction in the journal-based approach involves simply
    _____
    the journal file.
    Hint

    Once committed, the journal is no longer needed.

    Answer

    deleting

  29. 29
    MKDB uses a network protocol inspired by
    _____
    .
    Hint

    This popular in-memory data store has a simple text-based protocol.

    Answer

    Redis

1 of 29
Question 1 of 29

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent