1. Home
  2. Explore
  3. Computer Science
  4. SQL Basics for Beginners

Study methods

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

SQL Basics for Beginners

  • 70Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Data and SQL
Facts about a person or activity that can be analyzed to gain insight are called
.

70 questions

  1. 1
    Facts about a person or activity that can be analyzed to gain insight are called
    _____
    .
    Hint

    Think of the facts and attributes collected about a person, object, or activity.

    Answer

    data

    Explanation

    Data consists of facts about something that describe it and can provide insight into it.

  2. 2
    Extracting meaning from data helps people make
    _____
    .
    Hint

    Consider what useful understanding of data can help people do.

    Answer

    meaningful decisions

    Explanation

    Analyzing data and extracting meaning from it can help people make informed decisions.

  3. 3
    A dedicated storage location for data is a
    _____
    .
    Hint

    Think of the organized storage location used to hold data.

    Answer

    database

    Explanation

    A database is a dedicated place for storing data so it can be managed and used.

  4. 4
    SQL is a
    _____
    used to communicate with a database and work with its data.
    Hint

    SQL is a language used to ask a database for information and perform actions on it.

    Answer

    query language

    Explanation

    SQL is a query language used to communicate with databases and retrieve or manipulate data.

  5. 5
    A
    _____
    processes an SQL query and can return its results.
    Hint

    What kind of database system processes queries for relational databases?

    Answer

    relational database management system

    Explanation

    An RDBMS processes SQL queries and returns their results.

  6. 6
    In a relational table, each row represents a
    _____
    .
    Hint

    In a table, what is another name for a row of related details?

    Answer

    records

    Explanation

    In a relational database, each record is represented by a row containing related attribute values.

  7. 7
    A unique identifier used to distinguish a record in a table is its
    _____
    .
    Hint

    Think of the unique identifier that distinguishes one record from others.

    Answer

    primary key

    Explanation

    A primary key identifies a particular record in a table.

  8. 8
    The location where an attribute is stored is called a
    _____
    .
    Hint

    Think of a location in a table where an attribute's value is kept.

    Answer

    field

    Explanation

    A field is a location in which an attribute is stored.

  9. 9
    Attributes such as name, age, and address are represented by table
    _____
    .
    Hint

    In a table, which direction represents attributes shared by records?

    Answer

    columns

    Explanation

    Columns represent attributes that describe the records in a table, such as name, age, or address.

  10. 10
    The individual records in a table are stored as
    _____
    .
    Hint

    Each horizontal entry holds the details of one record.

    Answer

    rows

    Explanation

    Rows are records, each containing details for a particular entry in the table.

  11. 11
    In a database,
    _____
    represents a missing value rather than the number zero.
    Hint

    This database value indicates that information is absent rather than numerically zero.

    Answer

    NULL

    Explanation

    A NULL value represents missing or empty information for an attribute; it is not the same as zero.

  12. 12
    To require that an attribute always have a value, define it as
    _____
    .
    Hint

    Which setting prevents an attribute from having a missing value?

    Answer

    NOT NULL

    Explanation

    The NOT NULL constraint requires an attribute to have a value and prevents it from being left empty.

  13. 13
    Rules that restrict which data can be entered into a table are called
    _____
    .
    Hint

    Think of table rules that limit which data is acceptable.

    Answer

    constraints

    Explanation

    Constraints define rules that restrict what data can be entered into a table.

  14. 14
    A table stores a unique set of data with a
    _____
    across its records.
    Hint

    Think of what remains structured consistently across the records in a table.

    Answer

    consistent number of typed data attributes

    Explanation

    A table contains a consistent set of columns, each representing a typed data attribute.

  15. 15
    A table uses a
    _____
    to uniquely identify each of its records.
    Hint

    Which key must be unique for every record?

    Answer

    primary key

    Explanation

    A primary key uniquely identifies each record, so its value cannot be duplicated among records in the table.

  16. 16
    Because a primary key uniquely identifies each record, it helps avoid identification issues caused by
    _____
    .
    Hint

    A unique identifier avoids problems caused by repeated or non-unique identifying details.

    Answer

    redundancy

    Explanation

    A unique primary key helps locate a record without relying on potentially repeated values such as names, reducing identification problems caused by redundancy.

  17. 17
    A child table uses a
    _____
    to refer to a primary key in its parent table.
    Hint

    The key in the child table refers back to a key in the parent table.

    Answer

    foreign key

    Explanation

    A primary key from a parent table can be stored in a child table as a foreign key to define their relationship.

  18. 18
    When a child table refers to another table's primary key, the referenced table is the
    _____
    .
    Hint

    Which side of a parent-child relationship supplies the referenced key?

    Answer

    parent

    Explanation

    In the described parent-child relationship, the table whose primary key is referenced is the parent table.

  19. 19
    In a parent-child table relationship, the table containing the foreign key is the
    _____
    .
    Hint

    Which side contains the key that points to the parent?

    Answer

    child

    Explanation

    The child table contains the foreign key that refers to the primary key in the parent table.

  20. 20
    In a relational database, connections between tables are called
    _____
    .
    Hint

    These connections explain how one table relates to another.

    Answer

    relationships

    Explanation

    Relationships describe how tables are connected within a relational database.

  21. 21
    The concept that indicates whether a parent-to-child relationship is optional or required is
    _____
    .
    Hint

    Think of whether a table-to-table relationship must exist or may be absent.

    Answer

    ordinality

    Explanation

    Ordinality indicates whether the relationship from a parent table to a child table is optional or required.

  22. 22
    In the described relationship notation, an optional relationship is represented by a
    _____
    .
    Hint

    The optional relationship is marked with which numeral?

    Answer

    zero

    Explanation

    In the described relationship notation, zero indicates that the relationship is optional.

  23. 23
    A required relationship is represented by a straight
    _____
    .
    Hint

    The required relationship is indicated by a straight mark rather than a zero.

    Answer

    perpendicular line

    Explanation

    A straight perpendicular line indicates that a relationship is required rather than optional.

  24. 24
    The concept describing patterns such as one-to-one and one-to-many relationships is
    _____
    .
    Hint

    Think of relationship patterns such as one-to-one and one-to-many.

    Answer

    cardinality

    Explanation

    Cardinality describes the type or number pattern of a relationship, such as one-to-one or one-to-many.

  25. 25
    When one parent record can relate to multiple child records, the relationship is
    _____
    .
    Hint

    This pattern means one record on one side can relate to multiple records on the other.

    Answer

    one-to-many

    Explanation

    One-to-many is one of the relationship types that cardinality can describe.

  26. 26
    SQL commands used to define tables and databases belong to
    _____
    .
    Hint

    Which SQL language category is used to define database structures?

    Answer

    Data Definition Language

    Explanation

    Data Definition Language (DDL) commands define database structures such as databases and tables.

  27. 27
    The DDL command used to create a database or table is
    _____
    .
    Hint

    Which DDL command builds a new database object?

    Answer

    CREATE

    Explanation

    CREATE is used to create a database or a table.

  28. 28
    To delete a table or database completely, use the
    _____
    command.
    Hint

    Which command removes the table structure as well as the table?

    Answer

    DROP

    Explanation

    DROP deletes a table or database itself, rather than merely emptying it.

  29. 29
    The command that removes a table's records while keeping its structure is
    _____
    .
    Hint

    Which command empties a table but keeps its name and attributes?

    Answer

    TRUNCATE

    Explanation

    TRUNCATE removes all records from a table while leaving the table structure available for reuse.

  30. 30
    The DDL command used to change a table's structure is
    _____
    .
    Hint

    Which DDL command modifies a table definition?

    Answer

    ALTER

    Explanation

    ALTER is used to change a table's structure or definition.

  31. 31
    The command described as adding notes to a data dictionary is
    _____
    .
    Hint

    Which command is used to add explanatory notes to a data dictionary?

    Answer

    comment

    Explanation

    The content describes the comment command as a way to add comments to a data dictionary.

  32. 32
    Commands used to manipulate data in a database belong to
    _____
    .
    Hint

    Which SQL language category covers commands that manipulate database data?

    Answer

    Data Manipulation Language

    Explanation

    Data Manipulation Language (DML) commands are used to work with data in a database.

  33. 33
    To select a particular database for subsequent work, use the
    _____
    command.
    Hint

    Which command switches the active database?

    Answer

    USE

    Explanation

    USE selects a particular database to work with when multiple databases are available.

  34. 34
    The command used to add values into a table is
    _____
    .
    Hint

    Which command adds new records to a table?

    Answer

    INSERT INTO

    Explanation

    INSERT INTO adds values to a table.

  35. 35
    To change values in existing records, use the
    _____
    command.
    Hint

    Which command corrects or changes values in existing rows?

    Answer

    UPDATE

    Explanation

    UPDATE changes values in existing records, often targeting records with a WHERE clause.

  36. 36
    To remove a particular record from a table, use the
    _____
    command.
    Hint

    Which command removes rows rather than changing their values?

    Answer

    DELETE

    Explanation

    DELETE removes selected records from a table; a WHERE clause can target particular rows.

  37. 37
    The command used to retrieve data from a table is
    _____
    .
    Hint

    Which command asks a database to return chosen data?

    Answer

    SELECT

    Explanation

    SELECT retrieves or queries data from a table.

  38. 38
    Commands that manage database access privileges belong to
    _____
    .
    Hint

    Which SQL language category covers granting and withdrawing access privileges?

    Answer

    Data Control Language

    Explanation

    Data Control Language (DCL) includes commands that manage users' database privileges.

  39. 39
    The DCL command that gives users access privileges is
    _____
    .
    Hint

    Which command gives users database privileges?

    Answer

    GRANT

    Explanation

    GRANT gives a user privileges to access a database.

  40. 40
    The DCL command that withdraws previously granted privileges is
    _____
    .
    Hint

    Which command takes back previously assigned database privileges?

    Answer

    REVOKE

    Explanation

    REVOKE withdraws privileges that were previously granted to a user.

  41. 41
    CRUD stands for
    _____
    , the four basic operations performed on data.
    Hint

    Expand the four letters in CRUD as basic data actions.

    Answer

    create, read, update, and delete

    Explanation

    CRUD stands for create, read, update, and delete, the basic operations performed on data.

  42. 42
    Commands that control database transactions belong to
    _____
    .
    Hint

    Which SQL language category includes commands that commit or roll back transactions?

    Answer

    Transaction Control Language

    Explanation

    Transaction Control Language (TCL) includes commands that control transactions, such as COMMIT and ROLLBACK.

  43. 43
    To save changes made in a transaction, use
    _____
    .
    Hint

    Which transaction command makes changes permanent?

    Answer

    COMMIT

    Explanation

    COMMIT saves the changes made in a transaction.

  44. 44
    To undo transaction changes and return to the previous committed state, use
    _____
    .
    Hint

    Which command undoes uncommitted transaction changes?

    Answer

    ROLLBACK

    Explanation

    ROLLBACK reverses changes in a transaction and returns to the previous committed state.

  45. 45
    The transaction command that marks a point for later reference is
    _____
    .
    Hint

    This command marks a point in a transaction, much like saving progress in a game.

    Answer

    SAVEPOINT

    Explanation

    SAVEPOINT creates a named point within a transaction that can be used as a reference during transaction control.

  46. 46
    To specify characteristics for a transaction, use
    _____
    .
    Hint

    Which command is used to specify transaction characteristics?

    Answer

    SET TRANSACTION

    Explanation

    SET TRANSACTION specifies characteristics for a transaction.

  47. 47
    In the demonstrated MySQL commands, a query is ended with a
    _____
    .
    Hint

    Which punctuation mark terminates a query in the demonstration?

    Answer

    semicolon

    Explanation

    In the demonstrated MySQL interaction, a semicolon at the end tells MySQL that the query is complete.

  48. 48
    To retrieve every column from the customer table, write
    _____
    .
    Hint

    The star is a wildcard meaning all columns; use it with the customer table.

    Answer

    SELECT star FROM customer

    Explanation

    The star selects all columns, so this query returns all attributes from the customer table.

  49. 49
    The clause used to target records that meet a condition is
    _____
    .
    Hint

    Which clause narrows query results to records meeting a condition?

    Answer

    WHERE

    Explanation

    WHERE filters rows so a query can target records that match a condition.

  50. 50
    To find customers who meet a city condition and a product condition at the same time, connect the conditions with
    _____
    .
    Hint

    Use this logical operator when both specified conditions must be satisfied.

    Answer

    AND

    Explanation

    AND requires both conditions in a query to be true, such as matching both a city and a product.

  51. 51
    To arrange query results according to a chosen column, use
    _____
    .
    Hint

    Which clause arranges the returned rows according to a column?

    Answer

    ORDER BY

    Explanation

    ORDER BY sorts query results using the selected column.

  52. 52
    If an ORDER BY direction is omitted, results are sorted in
    _____
    order by default.
    Hint

    The default order proceeds from lower values to higher values.

    Answer

    ascending

    Explanation

    When no direction is specified for ORDER BY in the described behavior, results are ordered ascending by default.

  53. 53
    To sort results from higher values to lower values, add
    _____
    to ORDER BY.
    Hint

    Which short keyword requests the reverse of ascending order?

    Answer

    DESC

    Explanation

    DESC requests descending order, placing higher values before lower values.

  54. 54
    To calculate the total income across selected records, use the
    _____
    function.
    Hint

    Which aggregate function adds values together?

    Answer

    SUM

    Explanation

    SUM calculates the total of the values in a numeric column, optionally after filtering rows.

  55. 55
    To calculate the average value in a column, use the
    _____
    function.
    Hint

    Which aggregate function computes the mean?

    Answer

    AVG

    Explanation

    AVG calculates the average of values in a column.

  56. 56
    To find the highest income in a column, use the
    _____
    function.
    Hint

    Which aggregate function finds the greatest value?

    Answer

    MAX

    Explanation

    MAX returns the largest value in a column.

  57. 57
    To find the lowest income in a column, use the
    _____
    function.
    Hint

    Which aggregate function finds the least value?

    Answer

    MIN

    Explanation

    MIN returns the smallest value in a column.

  58. 58
    To count customer entries in a query result, use the
    _____
    function.
    Hint

    Which aggregate function returns how many entries match?

    Answer

    COUNT

    Explanation

    COUNT counts values or records matching the query; the described example counts a non-null name field.

  59. 59
    To return each customer name only once even if it appears in multiple records, use
    _____
    .
    Hint

    Which keyword eliminates duplicate values from a result?

    Answer

    DISTINCT

    Explanation

    DISTINCT removes duplicate values from the query results, allowing each name to appear only once.

  60. 60
    To retrieve related fields from the customer and product tables together, use a
    _____
    .
    Hint

    Which query operation brings together related rows from different tables?

    Answer

    JOIN

    Explanation

    JOIN combines related data from multiple tables so fields from both can be returned in one query.

  61. 61
    In the product model table, the field that refers to the associated customer record is the
    _____
    .
    Hint

    Which field in a product record points back to its customer?

    Answer

    customer ID

    Explanation

    The customer ID in the product table refers to a customer record and serves as a foreign key.

  62. 62
    In the table demonstration, the ID and age attributes use the
    _____
    data type.
    Hint

    Which data type is appropriate for whole-number values such as age or an ID?

    Answer

    integer

    Explanation

    The demo defines ID and age as integer-valued attributes using the integer type.

  63. 63
    The demo uses
    _____
    for text attributes such as names and cities.
    Hint

    Which type is used for text whose length can vary up to a specified limit?

    Answer

    VARCHAR

    Explanation

    VARCHAR is used for variable-length character strings such as names, cities, and product names.

  64. 64
    In the demonstration, the name field is defined as VARCHAR with a limit of
    _____
    characters.
    Hint

    What character limit was used for the example name and city fields?

    Answer

    30

    Explanation

    The demonstrated VARCHAR attributes for name, city, and product are assigned a limit of 30 characters.

  65. 65
    To have MySQL automatically advance an ID for each inserted record, use
    _____
    .
    Hint

    Which setting automatically generates the next identifier for a new row?

    Answer

    AUTO INCREMENT

    Explanation

    AUTO INCREMENT automatically advances the ID when a new record is inserted, avoiding manual ID entry.

  66. 66
    In the MySQL demonstration, the command that lists databases is
    _____
    .
    Hint

    Which command displays the available databases?

    Answer

    show databases

    Explanation

    The demonstrated show databases command lists the databases available in MySQL.

  67. 67
    In the MySQL demonstration, the command that lists tables is
    _____
    .
    Hint

    Which command lists tables in the selected database?

    Answer

    show tables

    Explanation

    The demonstrated show tables command lists the tables in the currently selected database.

  68. 68
    After creating a database, the demonstration selects it with the
    _____
    command.
    Hint

    Which command makes a chosen database active?

    Answer

    use

    Explanation

    The USE command selects a database and makes it the active database for subsequent work.

  69. 69
    A
    _____
    constraint prevents a product record from referring to a nonexistent customer record.
    Hint

    Which constraint checks that a reference in one table matches a record in another?

    Answer

    foreign key

    Explanation

    The foreign key constraint ensures that a referenced customer ID corresponds to a valid customer record, preventing a product row from referring to a nonexistent customer.

  70. 70
    The foreign-key option used to cascade a parent deletion to related rows is
    _____
    .
    Hint

    Which foreign-key option makes deletion of a parent affect related child rows?

    Answer

    ON DELETE CASCADE

    Explanation

    ON DELETE CASCADE specifies that deleting a referenced parent record can cascade to related child records.

1 of 70
Question 1 of 70

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent