3.7 Structured Query Language

Cards (31)

  • What is SQL?
    A programming language specifically used to manage database systems.
  • What is a database?
    A collection of information organized for easy access and management.
  • What is a relational database?
    A collection of database tables connected through relations.
  • What are the key terms related to databases?
    • Table: set of data stored as rows and columns
    • Record: collection of data stored as a row
    • Field: column within a table
    • Data type: specifies type of data allowed
    • Primary key: unique ID for records
    • Foreign key: links data between tables
  • What are the advantages of relational databases?
    They reduce data inconsistency and redundancy.
  • What is the SQL command to search for data?
    SELECT fields FROM tableName WHERE condition ORDER BY field;
  • What does the wildcard * do in SQL?
    It returns all records for a given condition.
  • How do you retrieve data from multiple tables in SQL?
    By using foreign keys to link the tables.
  • What is the purpose of a primary key?
    To uniquely identify records in a table.
  • What is the purpose of a foreign key?
    To link data between tables.
  • What is the SQL command to insert new data?
    INSERT INTO table_name (column1, column2…) VALUES (value1, value2…)
  • What is the SQL command to update current data?
    UPDATE table_name SET column1 = value1 WHERE condition
  • What is the SQL command to delete data?
    DELETE FROM table_name WHERE condition
  • What is SQL used for?
    SQL is used to manage database systems.
  • What is a database?
    A database is a collection of information organized for easy access and management.
  • How is a relational database structured?
    A relational database consists of database tables organized and connected through relations.
  • What is a primary key?
    A primary key is a unique ID that identifies records in a table.
  • What is a foreign key?
    A foreign key is an ID used to link data between tables.
  • What are the key terms related to database tables?
    • Table: a set of data stored as rows and columns
    • Record: a collection of data stored as a row in a table
    • Field: a column within a table used to store data
    • Data type: an attribute that specifies the type of data allowed
  • What are the advantages of relational databases?
    • Data is structured and organized
    • Reduces data inconsistency
    • Minimizes data redundancy (copies of data in multiple tables)
  • What is the SQL command to search for data?
    The command is SELECT fields FROM tableName WHERE condition ORDER BY field;
  • What does the wildcard * do in SQL?
    It returns all the records for a given condition.
  • What would the SQL command SELECT StudentName from Students WHERE Points < 0 ORDER BY StudentName ASC return?
    It returns "Kirstie" and "Marian" ordered in ascending order.
  • How do relational databases allow data retrieval from multiple tables?
    • Data is linked through foreign keys.
    • Primary keys cannot be duplicated.
    • Foreign keys can be duplicated within the same table.
  • How would you join two tables using foreign keys in SQL?
    You can use SELECT with a WHERE clause or the JOIN method.
  • What is the format for inserting new data into a table?
    INSERT INTO table_name (column1, column2…) VALUES (value1, value2…)
  • How would you insert a new student named Michael into the Students table?
    INSERT INTO Students (StudentName, Detail, Points, LetterSent) VALUES ("Michael", "Good work in class", 1, FALSE);
  • What is the format for updating current data in a table?
    UPDATE table_name SET column1 = value1, column2 = value2… WHERE condition;
  • How would you update Kirstie’s letter status to TRUE?
    UPDATE Students SET LetterSent = TRUE WHERE StudentName = "Kirstie";
  • What is the format for deleting data from a table?
    DELETE FROM table_name WHERE condition;
  • How would you delete Marian from the Students table?
    DELETE FROM Students WHERE StudentName = "Marian";