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 & Databases
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is data, and how can it help people or businesses make decisions?

Tap to flipClick to flipspace

Data consists of facts or attributes about something. Examining it can provide insights that support better decisions.

Or swipe the card

70 cards

  1. What is data, and how can it help people or businesses make decisions?

    Data consists of facts or attributes about something. Examining it can provide insights that support better decisions.

  2. How can data analysis benefit a business?

    Businesses can analyze data to improve decisions, increase profits, and operate more efficiently.

  3. What is a database?

    A database is a dedicated location for storing and managing data.

  4. What are some purposes of a database beyond simply storing data?

    Databases help store, manipulate, update, secure, analyze, process, and represent data.

  5. How can a database help turn stored data into useful information?

    Analyzing and processing stored data can reveal meaningful patterns and insights that support decision-making.

  6. What customer attributes does the tutorial give as examples of useful data?

    A customer's age, income, and buying habits are examples of attributes that can be recorded and analyzed.

  7. What is SQL?

    SQL is a query language used to communicate with databases, retrieve data, and perform actions on it.

  8. How may SQL be pronounced?

    SQL is commonly pronounced either “S-Q-L” or “sequel”; the tutorial says either pronunciation is acceptable.

  9. What happens when a SQL query is sent to a database?

    A SQL statement is sent to a database or relational database management system (RDBMS), which processes it and returns a result.

  10. What does SELECT name FROM customers; ask the database to return?

    For example, SELECT name FROM customers; requests the name values from the customers table.

  11. What kinds of actions can SQL perform on database data?

    SQL can be used to retrieve, manipulate, and delete data in a database.

  12. Why is SQL useful in business intelligence?

    SQL is widely used in business intelligence because BI work involves handling and querying data.

  13. What is a table in a relational database?

    A table is a basic database structure for storing a consistent set of data attributes.

  14. What do rows and columns represent in a table?

    Rows represent records, while columns represent attributes that describe those records.

  15. In a customer table, what is an example of a row and of a column?

    A row is one record, such as the details for one customer; a column is one attribute, such as name, age, or address.

  16. What does the tutorial mean by a field in a table?

    A field is a location in a table where an attribute's value is stored.

  17. What is the difference between allowing NULL and declaring a column NOT NULL?

    A NULL value represents an absent or unknown value. A NOT NULL constraint requires a value to be supplied.

  18. What is a database constraint?

    A constraint is a rule that restricts which data can be entered into a table.

  19. What is the purpose of a primary key?

    A primary key uniquely identifies each record in a table and must not be duplicated.

  20. Why might a table use an ID rather than a person's name as its primary key?

    An ID column is a common primary-key choice because it can uniquely identify records even when other values, such as names, are not unique.

  21. What is a foreign key?

    A foreign key is a column in a child table that refers to a key in a related parent table.

  22. In a parent-child table relationship, where are the referenced key and foreign key located?

    The parent table contains the referenced key; the child table contains the corresponding foreign-key column.

  23. What does ordinality describe, and how does the tutorial represent optional versus required relationships?

    Ordinality describes whether a relationship between a parent and child is optional or required. The tutorial represents optionality with zero and required participation with a straight line.

  24. What does cardinality describe? Give examples of cardinalities.

    Cardinality describes how many instances of one table can relate to instances of another, such as one-to-one, one-to-many, or many-to-many.

  25. What is DDL, and which commands does the tutorial associate with it?

    DDL defines or changes database structures. The tutorial lists CREATE, DROP, TRUNCATE, ALTER, and COMMENT among its commands.

  26. What does the CREATE command do?

    CREATE creates a database or table.

  27. What does the DROP command do?

    DROP removes a table or database structure.

  28. How does TRUNCATE differ from DROP?

    TRUNCATE removes all records from a table while leaving the table structure in place.

  29. What is the purpose of the ALTER command?

    ALTER changes an existing database object, such as a table.

  30. What use for COMMENT does the tutorial mention?

    The tutorial describes COMMENT as a command used to add comments to a data dictionary.

  31. What is DML, and which common commands does the tutorial list?

    DML is used to work with data in tables. The tutorial includes INSERT, UPDATE, DELETE, and SELECT among its commands.

  32. Which command is used to add values to a table?

    INSERT INTO adds values to a table.

  33. Which command changes values in existing records?

    UPDATE changes values in existing records.

  34. Which command removes records from a table?

    DELETE removes records from a table.

  35. What do GRANT and REVOKE do?

    DCL controls database access privileges. GRANT gives privileges, while REVOKE withdraws privileges.

  36. What is TCL, and which commands does the tutorial list for it?

    TCL manages transactions. The tutorial lists COMMIT, ROLLBACK, SAVEPOINT, and SET TRANSACTION.

  37. What does COMMIT do?

    COMMIT saves the changes made in a transaction.

  38. What does ROLLBACK do?

    ROLLBACK undoes transaction changes, such as changes made after the previous commit.

  39. What is a SAVEPOINT used for?

    SAVEPOINT marks a point within a transaction to save its progress.

  40. What does SET TRANSACTION specify?

    SET TRANSACTION specifies characteristics for a transaction.

  41. What does CRUD stand for?

    CRUD stands for Create, Read, Update, and Delete—the basic operations for working with data.

  42. In the MySQL demonstration, what do SHOW DATABASES; and SHOW TABLES; display?

    SHOW DATABASES; lists databases, and SHOW TABLES; lists tables in the selected database.

  43. How do you select a database to work in using the demonstrated MySQL command?

    USE database_name; selects a database to work in.

  44. How does the MySQL session in the tutorial indicate that a statement is complete?

    A semicolon marks the end of a SQL statement in the demonstrated MySQL session.

  45. Why are SQL keywords sometimes capitalized, and must they be capitalized in the tutorial's examples?

    SQL keywords are shown in uppercase for readability, but the tutorial notes that capitalization is not required in its examples.

  46. What does SELECT * FROM customer; retrieve?

    SELECT * FROM customer; retrieves all columns from the customer table.

  47. How can a query return only selected columns from a table?

    List the required column names after SELECT, separated by commas; for example, SELECT name, age FROM customer; returns only those columns.

  48. What does the WHERE clause do?

    WHERE filters rows according to a condition, such as WHERE city = 'Mumbai'.

  49. How can a query require that two filtering conditions both be met?

    Use AND to require both conditions to be true, such as filtering for both a city and a product.

  50. What does ORDER BY do?

    ORDER BY sorts query results by a chosen column.

  51. What is the default sort direction in the tutorial's ORDER BY example, and how do you request descending order?

    If no direction is specified, the tutorial's example sorts in ascending order. Use DESC to sort in descending order.

  52. What is the basic pattern for inserting values, and how should string values be written?

    Use INSERT INTO table_name (columns) VALUES (values);. String values are enclosed in quotes; numeric values are entered without string quotes.

  53. What is the purpose of an auto-incrementing ID column?

    An auto-incrementing ID is generated automatically as records are inserted, so the user does not need to enter each ID manually.

  54. Which column types does the tutorial use for integers and variable-length strings, and what does the number in VARCHAR(n) indicate?

    For an integer column, use INT; for a variable-length string, use VARCHAR(n), where n sets the allowed length.

  55. How can you update a value for a specific record without changing every record in the table?

    UPDATE customer SET city = 'Mumbai' WHERE ...; changes selected values. The WHERE condition targets the records to update.

  56. How does DELETE remove a particular record, and why is filtering important?

    DELETE removes rows matching its condition; without a suitable filter, it may remove more rows than intended.

  57. What does the SQL aggregate SUM calculate?

    SUM(column) returns the total of the column's values.

  58. What does the SQL aggregate AVG calculate?

    AVG(column) returns the average of the column's values.

  59. What do the MAX and MIN aggregates return?

    MAX(column) returns the largest value in a column; MIN(column) returns the smallest.

  60. What does COUNT(column) count, and why can NULL values matter?

    COUNT(column) counts non-NULL values in that column. A column declared NOT NULL is useful when every record should be countable by that column.

  61. How can you calculate an aggregate for only rows that meet a condition?

    Add a WHERE clause to an aggregate query to limit which records contribute to the result—for example, summing income only for customers who bought a phone.

  62. What does DISTINCT do in a query?

    DISTINCT removes duplicate values from the selected results, such as listing each customer name only once.

  63. What does a foreign-key constraint enforce?

    A foreign-key constraint ensures that a child-table value refers to an existing key in the parent table.

  64. What happens if you insert a foreign-key value that has no matching parent-table key?

    If a foreign key references a customer ID, inserting a child-row value for a customer ID that does not exist in the customer table causes an error.

  65. Which foreign-key option does the tutorial include for handling a parent-row deletion?

    ON DELETE CASCADE is the foreign-key option shown in the tutorial's constraint example.

  66. Why use a join in a relational database?

    A join combines related data from multiple tables, allowing a query to return selected fields from each.

  67. How can you specify which table a selected column belongs to?

    Use a table name followed by a dot and a column name—such as customer.name—to identify which table a column comes from.

  68. What relationship is used to match rows when joining related tables?

    Join related tables by matching their linked key columns, such as a customer ID in one table with the corresponding customer key in another.

  69. What is an example of information that a join between customer and product tables can retrieve?

    A join query can return customer details, such as name and income, alongside product details, such as product name and price.

  70. What is the general sequence of steps in the MySQL demonstration before querying data?

    The tutorial demonstrates creating a database, selecting it with USE, creating tables with columns and constraints, inserting records, and querying the results.

Card 1 of 70
Card 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