1. Home
  2. Explore
  3. Computer Science
  4. SQL and Database Fundamentals

Study methods

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

SQL and Database Fundamentals

  • 114Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Query Foundations
The language used to retrieve and manage data in relational databases, and a common standard across applications, is
.

114 questions

  1. 1
    The language used to retrieve and manage data in relational databases, and a common standard across applications, is
    _____
    .
    Hint

    It is the language at the center of the database concepts in this material.

    Answer

    SQL

  2. 2
    In a basic retrieval query, the SELECT statement specifies the data or
    _____
    to return.
    Hint

    These are the named pieces of information stored in a table.

    Answer

    columns

  3. 3
    In a basic retrieval query, the FROM clause identifies the
    _____
    that contains the requested data.
    Hint

    It is the database structure from which rows are retrieved.

    Answer

    table

  4. 4
    In a SELECT list, the asterisk is shorthand for retrieving
    _____
    columns.
    Hint

    It requests every column in the selected table.

    Answer

    all

  5. 5
    In production queries, explicitly listing needed columns instead of using an asterisk can reduce unnecessary data retrieval and
    _____
    load.
    Hint

    This refers to the database's reading and writing workload.

    Answer

    IO

  6. 6
    The clause that filters individual rows according to conditions is
    _____
    .
    Hint

    It keeps rows that satisfy a specified condition.

    Answer

    WHERE

  7. 7
    SQL comparison operators can compare numbers, dates, and text, including testing whether a value is greater than or
    _____
    a specified value.
    Hint

    It is the opposite direction from greater than.

    Answer

    less than

  8. 8
    The LIKE operator searches text for a pattern, and the percent sign wildcard matches any sequence of characters, including
    _____
    characters.
    Hint

    A pattern can match an empty sequence as well as a longer one.

    Answer

    no

  9. 9
    To require that both a product's category and color conditions are true, combine them with the logical operator
    _____
    .
    Hint

    This operator narrows results by requiring every joined condition to be true.

    Answer

    AND

  10. 10
    To include rows that satisfy either one condition or another, use the logical operator
    _____
    .
    Hint

    Unlike AND, this operator can broaden the results.

    Answer

    OR

  11. 11
    When AND and OR appear together, parentheses clarify the intended grouping because
    _____
    has higher precedence by default.
    Hint

    SQL evaluates this operator before OR unless parentheses change the order.

    Answer

    AND

  12. 12
    The logical operator that reverses the truth of a condition is
    _____
    .
    Hint

    It turns a condition into its opposite.

    Answer

    NOT

  13. 13
    The SELECT keyword that removes duplicate result rows and returns unique values is
    _____
    .
    Hint

    It is useful when a report needs a list of manufacturers rather than every sale.

    Answer

    DISTINCT

  14. 14
    When DISTINCT is applied to multiple selected columns, it identifies unique
    _____
    of values across those columns.
    Hint

    For example, a manufacturer and color together form a single unit for comparison.

    Answer

    combinations

  15. 15
    The clause that sorts query results without changing which data is returned is
    _____
    .
    Hint

    It controls the sequence in which results are presented.

    Answer

    ORDER BY

  16. 16
    Unless specified otherwise, ORDER BY sorts in
    _____
    order, such as A to Z for text and smallest to largest for numbers.
    Hint

    This is the default direction of sorting.

    Answer

    ascending

  17. 17
    To show the most expensive products first, a query can sort price in
    _____
    order.
    Hint

    This sorting direction runs from largest to smallest.

    Answer

    descending

  18. 18
    When ORDER BY lists category before price, SQL sorts by category first and then sorts prices within each category; this is sorting by
    _____
    columns.
    Hint

    More than one field can determine the order.

    Answer

    multiple

  19. 19
    SQL can turn raw sales records into business insights used for decisions such as inventory planning and detecting potential
    _____
    .
    Hint

    This is an example of an unusual pattern businesses may want to identify.

    Answer

    fraud

  20. 20
    The clause that divides rows into groups based on shared values in one or more columns is
    _____
    .
    Hint

    It makes it possible to calculate totals separately for categories or brands.

    Answer

    GROUP BY

  21. 21
    The aggregate function that counts the number of rows in each group is
    _____
    .
    Hint

    It answers questions such as how many products a brand supplies.

    Answer

    COUNT

  22. 22
    To calculate total revenue or add values in a numeric column within each group, use the aggregate function
    _____
    .
    Hint

    It adds the group's numeric values together.

    Answer

    SUM

  23. 23
    The aggregate function that calculates the mean of a numeric column within each group is
    _____
    .
    Hint

    It produces the arithmetic average.

    Answer

    AVG

  24. 24
    To find the smallest value in a group, use the aggregate function
    _____
    .
    Hint

    It returns the minimum value.

    Answer

    MIN

  25. 25
    To find the largest value in a group, use the aggregate function
    _____
    .
    Hint

    It returns the maximum value.

    Answer

    MAX

  26. 26
    To calculate revenue for each product category, group rows by category and apply SUM to the product of price and quantity; an output label such as total revenue is an
    _____
    .
    Hint

    It gives a calculated output column a readable name.

    Answer

    alias

  27. 27
    The clause that filters groups after GROUP BY and aggregation is
    _____
    .
    Hint

    It can select categories whose aggregated revenue exceeds a threshold.

    Answer

    HAVING

  28. 28
    A query cannot use WHERE to filter on a result such as SUM because WHERE runs before
    _____
    .
    Hint

    This step forms groups for aggregate calculations.

    Answer

    GROUP BY

  29. 29
    Putting customer, product, manufacturer, and sale information into one large table can cause repeated data, a problem called
    _____
    .
    Hint

    For example, the same customer address could be stored with every purchase.

    Answer

    redundancy

  30. 30
    The design process of organizing data into related tables to reduce repetition and improve consistency is
    _____
    .
    Hint

    It separates information about entities such as customers, products, and sales.

    Answer

    normalization

  31. 31
    In a normalized design, each table generally focuses on one specific
    _____
    or subject, such as a customer or product.
    Hint

    It is the kind of thing about which a table stores information.

    Answer

    entity

  32. 32
    A primary key identifies each row in its table with a
    _____
    value.
    Hint

    No two rows in the table should share this identifying value.

    Answer

    unique

  33. 33
    A foreign key in one table contains a value that refers to the
    _____
    key in another table.
    Hint

    This is the unique identifier in the referenced table.

    Answer

    primary

  34. 34
    A sale record can refer to a customer's full record using a customer ID rather than repeating the customer's name and address; this link uses a
    _____
    key.
    Hint

    It connects a row to a key in another table.

    Answer

    foreign

  35. 35
    The most common join, which returns rows only when the join condition matches in both tables, is an
    _____
    join.
    Hint

    It returns the overlapping matches between the two tables.

    Answer

    INNER

  36. 36
    With an INNER JOIN between sales and products, a product that has never been sold is excluded because it has no
    _____
    row in the sales table.
    Hint

    The required link between the tables is absent for this product.

    Answer

    matching

  37. 37
    In an explicit join, the ON clause specifies the
    _____
    that tells the database how the tables are related.
    Hint

    It commonly matches a foreign key to a primary key.

    Answer

    join condition

  38. 38
    When a query joins several tables, listing only needed columns with their table names or aliases makes the query clearer and avoids
    _____
    columns.
    Hint

    These columns are not needed for the requested result.

    Answer

    unnecessary

  39. 39
    To retrieve sale, product, and manufacturer details, a query can follow their relationships by chaining
    _____
    together.
    Hint

    Each step links another related table into the query.

    Answer

    joins

  40. 40
    A temporary nickname such as S for the sale table, used to shorten references within a query, is a table
    _____
    .
    Hint

    It makes references to long table names more concise.

    Answer

    alias

  41. 41
    A LEFT JOIN retains every row from the table listed first and fills unmatched columns from the other table with
    _____
    values.
    Hint

    These values indicate missing or unknown data in the unmatched side.

    Answer

    NULL

  42. 42
    A RIGHT JOIN retains every row from the
    _____
    table in the join and fills unmatched columns from the other table with NULL values.
    Hint

    It keeps all rows from the table on the opposite side from a LEFT JOIN.

    Answer

    right

  43. 43
    A FULL OUTER JOIN keeps all rows from
    _____
    tables, using NULL values where a row has no match on the other side.
    Hint

    It combines the unmatched-row behavior of left and right joins.

    Answer

    both

  44. 44
    If a join condition is missing or incorrect, every row from one table may combine with every row from the other, producing a
    _____
    product.
    Hint

    This can cause an unexpectedly enormous result set.

    Answer

    Cartesian

  45. 45
    A NATURAL JOIN guesses which columns to match by looking for shared column names, so explicit joins are often preferred because they are more
    _____
    .
    Hint

    The query directly states the intended relationship instead of guessing.

    Answer

    explicit

  46. 46
    The data manipulation language command used to add new rows to a table is
    _____
    .
    Hint

    It places new records into an existing table.

    Answer

    INSERT

  47. 47
    When inserting data, explicitly naming the destination columns makes it clear which value corresponds to which
    _____
    .
    Hint

    The listed values must match these named fields.

    Answer

    column

  48. 48
    Explicitly listing INSERT columns also makes a statement more resilient if a new column is later added to the table, because it avoids relying on the table's default column
    _____
    .
    Hint

    Without a column list, values may depend on how fields are arranged.

    Answer

    order

  49. 49
    If an INSERT omits a column that has a defined default, the database assigns the column's
    _____
    value.
    Hint

    It is the value configured for use when no value is supplied.

    Answer

    default

  50. 50
    If an omitted column has no defined default, it will typically receive the value
    _____
    .
    Hint

    This represents a missing, unknown, or inapplicable value rather than zero.

    Answer

    NULL

  51. 51
    INSERT can copy selected rows from one table into another by using a SELECT statement, which is useful for tasks such as archiving old
    _____
    .
    Hint

    These records represent completed transactions that might be moved to an archive.

    Answer

    sales

  52. 52
    When a new sale references a customer ID that does not exist in the customer table, the database should reject the INSERT to preserve
    _____
    integrity.
    Hint

    This protects the validity of relationships between linked tables.

    Answer

    referential

  53. 53
    The database rejects an INSERT that tries to reuse an existing value for a row's
    _____
    key.
    Hint

    This key must uniquely identify each row.

    Answer

    primary

  54. 54
    The SQL statement for modifying existing rows uses SET to assign new values and a
    _____
    clause to identify which rows should change.
    Hint

    It restricts the update to records that meet a condition.

    Answer

    WHERE

  55. 55
    An UPDATE statement without a WHERE clause changes
    _____
    rows in the table.
    Hint

    No condition restricts which records are affected.

    Answer

    every

  56. 56
    Before running a potentially risky UPDATE, use a SELECT query with the same WHERE condition to
    _____
    the rows that would be affected.
    Hint

    This safety step lets you inspect the target records first.

    Answer

    preview

  57. 57
    The exact syntax for updating rows in multiple tables can vary across database
    _____
    .
    Hint

    Different products may support different forms of multi-table updates.

    Answer

    systems

  58. 58
    The SQL statement used to remove selected rows from a table is
    _____
    .
    Hint

    It removes records while leaving the table structure in place.

    Answer

    DELETE

  59. 59
    A DELETE statement without a WHERE clause removes
    _____
    rows from the table.
    Hint

    Without a condition, no records are excluded from the operation.

    Answer

    all

  60. 60
    Before running a DELETE, a SELECT with the same WHERE condition helps verify which records are about to be
    _____
    .
    Hint

    The query is a preview of the destructive operation.

    Answer

    deleted

  61. 61
    The foreign-key behavior that blocks deleting a parent row while dependent child rows still exist is called
    _____
    .
    Hint

    It is the protective behavior that prevents the deletion.

    Answer

    RESTRICT

  62. 62
    With the CASCADE foreign-key behavior, deleting a parent record automatically deletes its related
    _____
    records.
    Hint

    These are the dependent rows that refer to the parent.

    Answer

    child

  63. 63
    With the SET NULL foreign-key behavior, deleting a parent sets the corresponding foreign-key value in child rows to
    _____
    .
    Hint

    The child row remains, but its link to the deleted parent is cleared.

    Answer

    NULL

  64. 64
    A soft delete preserves a record physically but marks it as inactive or records a deletion date so normal application views can filter it
    _____
    .
    Hint

    The record remains available for auditing or reporting but is excluded from ordinary views.

    Answer

    out

  65. 65
    DROP TABLE removes the table's structure as well as its
    _____
    .
    Hint

    Unlike DELETE, it removes more than just the rows.

    Answer

    data

  66. 66
    Before dropping a significant table, one essential safeguard is to make a reliable, recent
    _____
    .
    Hint

    It can help recover data if the operation causes a problem.

    Answer

    backup

  67. 67
    Before dropping a table, checking which other tables, views, or procedures rely on it means checking its
    _____
    .
    Hint

    These are the database objects that may rely on the table.

    Answer

    dependencies

  68. 68
    Testing a DROP TABLE script in a development or staging environment before production is an example of testing in a
    _____
    environment.
    Hint

    It is separate from the live environment used for real operations.

    Answer

    non-production

  69. 69
    Adding IF EXISTS to a DROP TABLE script prevents an error if the table has already been removed or
    _____
    .
    Hint

    The clause handles the case where there is no such table to drop.

    Answer

    never existed

  70. 70
    If a child table has a foreign key referencing a parent table, the child table generally must be dropped
    _____
    the parent table.
    Hint

    Remove the dependent object first to avoid a dependency error.

    Answer

    before

  71. 71
    A sensible order for writing SQL is correctness first, readability second, and
    _____
    third.
    Hint

    This priority focuses on making a correct, understandable query faster only when needed.

    Answer

    optimization

  72. 72
    Adding comments that explain why complex query logic exists improves long-term code
    _____
    .
    Hint

    Comments help teammates understand and maintain a query.

    Answer

    readability

  73. 73
    When joining several tables, using table aliases consistently can make references shorter and more
    _____
    .
    Hint

    Aliases reduce clutter in complex queries.

    Answer

    readable

  74. 74
    Using explicit JOIN ... ON syntax rather than placing join conditions in WHERE separates table-linking logic from row
    _____
    logic.
    Hint

    This logic is commonly expressed with the WHERE clause.

    Answer

    filtering

  75. 75
    Putting selected columns and conditions on separate, consistently formatted lines helps make query
    _____
    visible.
    Hint

    Consistent formatting helps readers see how the query is organized.

    Answer

    structure

  76. 76
    In the conceptual SQL processing order, FROM and JOIN identify the initial set of candidate rows before WHERE filters them and GROUP BY forms
    _____
    .
    Hint

    These are collections of rows with shared values.

    Answer

    groups

  77. 77
    In the conceptual query processing order, HAVING filters groups before SELECT chooses output columns and ORDER BY
    _____
    the final results.
    Hint

    This last step controls the sequence in which rows are presented.

    Answer

    sorts

  78. 78
    Reducing unwanted rows early, such as with WHERE before GROUP BY, can improve performance by minimizing the database's search
    _____
    .
    Hint

    Fewer rows need to be carried through later operations.

    Answer

    space

  79. 79
    An index helps a database find rows without reading every row in a table, avoiding a full table
    _____
    when the index can be used.
    Hint

    Without an index, the database may have to inspect the entire table.

    Answer

    scan

  80. 80
    A database index stores indexed values in a structured order along with
    _____
    back to the corresponding table rows.
    Hint

    These lead from an index entry to the actual record.

    Answer

    pointers

  81. 81
    Indexes can speed up SELECT operations but slow INSERT, UPDATE, and DELETE operations because the database must keep the index structures
    _____
    when data changes.
    Hint

    The lookup structure must stay consistent with its table.

    Answer

    updated

  82. 82
    Strategic indexing often focuses on columns frequently used in WHERE conditions, JOIN conditions, or sometimes
    _____
    clauses.
    Hint

    This clause sorts results using specified columns.

    Answer

    ORDER BY

  83. 83
    A query condition is called sargable when it is written so the database can use an
    _____
    to find matching rows.
    Hint

    This lookup structure can avoid a full table scan.

    Answer

    index

  84. 84
    Applying a function directly to an indexed column in a WHERE condition can make the condition non-sargable because the database may need to evaluate the function for every
    _____
    .
    Hint

    Each record's column value may have to be transformed before comparison.

    Answer

    row

  85. 85
    For a date-range search, leaving the indexed date column unmodified and comparing it to range boundaries can allow the database to use its
    _____
    .
    Hint

    This is preferable to applying a year-extraction function to every date.

    Answer

    index

  86. 86
    A LIKE pattern with a leading percent sign, such as a search for text anywhere inside a name, usually prevents efficient
    _____
    use.
    Hint

    The database cannot readily use the beginning of the indexed text to locate an arbitrary substring.

    Answer

    index

  87. 87
    When testing for exact text equality, prefer an exact-match comparison over LIKE when possible, since it may be more efficient and
    _____
    .
    Hint

    The comparison should express exactly the condition needed.

    Answer

    precise

  88. 88
    When a subquery returns many rows, EXISTS may perform well because it checks whether a match is present and can stop after finding
    _____
    .
    Hint

    It does not need to enumerate every matching result to answer its existence question.

    Answer

    one

  89. 89
    To reduce join work, include only tables needed for selected data or filtering, and apply applicable filters to each table
    _____
    the join when possible.
    Hint

    Reducing input rows can make the join operation smaller.

    Answer

    before

  90. 90
    If nonmatching rows are not needed, an INNER JOIN is often faster than an outer join because the database does not need to preserve unmatched rows or generate their
    _____
    values.
    Hint

    These values appear in the missing side of an outer-join result.

    Answer

    NULL

  91. 91
    A query using a join can often avoid the repeated per-row work of a correlated
    _____
    .
    Hint

    This inner query refers back to a row in the outer query.

    Answer

    subquery

  92. 92
    In application code, fetching a list and then issuing a separate query for each item's details creates the
    _____
    query problem.
    Hint

    One query retrieves the list, followed by one additional query per item.

    Answer

    N plus one

  93. 93
    UNION removes duplicate rows from combined results, whereas UNION ALL preserves them and is often faster because it avoids duplicate
    _____
    .
    Hint

    This extra work may involve identifying repeated rows.

    Answer

    removal

  94. 94
    To investigate why a query is slow, a developer can use EXPLAIN or a similar tool to inspect its execution
    _____
    .
    Hint

    It describes the operations the database intends to perform.

    Answer

    plan

  95. 95
    An execution plan can show whether a query uses indexes or performs table scans, the join algorithms, row estimates, and operation
    _____
    or time.
    Hint

    These estimates help identify expensive steps.

    Answer

    cost

  96. 96
    A common table expression, defined with the WITH keyword, is a named temporary result set that exists for a single
    _____
    .
    Hint

    It can be referenced later in the statement that defines it.

    Answer

    query

  97. 97
    Using CTEs to define logical steps can make long, multi-step queries more
    _____
    and maintainable than deeply nested subqueries.
    Hint

    Named steps help a reader follow the query's structure.

    Answer

    readable

  98. 98
    Strategic denormalization intentionally adds controlled
    _____
    to reduce expensive joins in read-heavy applications.
    Hint

    It reintroduces some repeated data for a performance benefit.

    Answer

    redundancy

  99. 99
    Partitioning divides a very large table into smaller chunks based on a criterion such as
    _____
    ranges.
    Hint

    A table might have a separate partition for each month.

    Answer

    date

  100. 100
    SQL scripts should be tested in a dedicated development, staging, or test environment and never directly on a
    _____
    database.
    Hint

    This is the live environment containing real operational data.

    Answer

    production

  101. 101
    A repeatable database test often begins by creating the required table structures, also called the
    _____
    .
    Hint

    It describes the database's tables and their structure.

    Answer

    schema

  102. 102
    After creating test tables, a repeatable test loads a small, specific set of
    _____
    relevant to the test case.
    Hint

    These sample records provide a known input for the test.

    Answer

    test data

  103. 103
    After running the SQL being tested, verification queries check whether the database is in the expected
    _____
    .
    Hint

    The test checks the resulting data and structure against expectations.

    Answer

    state

  104. 104
    Cleaning up test tables by truncating or dropping them is called
    _____
    and helps the next test start fresh.
    Hint

    It is the cleanup phase at the end of a test.

    Answer

    tearing down

  105. 105
    After starting a transaction, a tester can inspect uncommitted changes and make them permanent with
    _____
    .
    Hint

    This transaction command finalizes the changes.

    Answer

    COMMIT

  106. 106
    If a transaction's changes are unwanted, the tester can use
    _____
    to undo changes made since the transaction began.
    Hint

    It restores the database to its state before the transaction.

    Answer

    ROLLBACK

  107. 107
    Containers such as Docker and in-memory databases such as SQLite can provide isolated database instances for
    _____
    .
    Hint

    These tools offer controlled environments separate from production.

    Answer

    testing

  108. 108
    A direct modification of production data should generally be a
    _____
    event requiring approval and strong justification.
    Hint

    Organizations should not treat these changes as routine or casual.

    Answer

    rare

  109. 109
    Correcting a clear factual error can support data accuracy, while changing historical records to misrepresent results is data
    _____
    .
    Hint

    This describes changes made to distort rather than accurately correct the record.

    Answer

    manipulation

  110. 110
    An audit trail records who made a change, what was changed, when it occurred, and
    _____
    it was made.
    Hint

    A change log may link this reason to a support ticket or bug report.

    Answer

    why

  111. 111
    To show what changed, an audit log may record the table, column, primary key, and the old and new
    _____
    .
    Hint

    They are the contents of the affected field before and after the change.

    Answer

    values

  112. 112
    Recording the user account or automated process that made a change answers the audit-trail question of
    _____
    .
    Hint

    It identifies the actor responsible for the change.

    Answer

    who

  113. 113
    An audit trail records
    _____
    a change occurred by capturing a precise timestamp.
    Hint

    This audit detail places the change in time.

    Answer

    when

  114. 114
    Transparent, traceable changes help maintain data integrity, accountability, and trust in the data's
    _____
    .
    Hint

    Auditors need to be able to verify how records changed over time.

    Answer

    history

1 of 114
Question 1 of 114

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent