SQL Q&A

  1. What is a database?
    A structured collection of data stored and accessed electronically.
  2. What is a DBMS?
    Database Management System; software that interacts with databases to manage data.
  3. What is SQL?
    Structured Query Language; a standard language for managing and manipulating databases.
  4. What is a primary key?
    A unique identifier for a record in a table.
  5. What is a foreign key?
    A field that links to the primary key of another table, establishing a relationship.
  6. What are the main data types in MySQL?
    Numeric (INT, DECIMAL), String (VARCHAR, TEXT), Date/Time (DATE, TIMESTAMP).
  7. What is the difference between CHAR and VARCHAR?
    CHAR is fixed-length; VARCHAR is variable-length, saving space.
  8. What is a NULL value?
    A value that represents the absence of data.
  9. What is a default value?
    A value automatically assigned to a column when no value is specified.
  10. What is a composite key?
    A key that consists of two or more columns used to uniquely identify a record.
  11. What is a SELECT statement?
    A SQL command used to retrieve data from a database.
  12. How do you filter records in SQL?
    Using the WHERE clause.
  13. What is an INNER JOIN?
    A join that returns rows with matching values in both tables.
  14. What is a LEFT JOIN?
    A join that returns all rows from the left table and matching rows from the right table.
  15. What is GROUP BY used for?
    To group rows that have the same values in specified columns.
  16. What is an index?
    A database structure that improves the speed of data retrieval operations.
  17. What is the difference between clustered and non-clustered index?
    A clustered index sorts and stores data rows, while a non-clustered index is a separate structure that references data rows.
  18. What are the advantages of using indexes?
    Faster search and retrieval times for data.
  19. What are the disadvantages of using indexes?
    Increased storage space and slower write operations (insert/update).
  20. What is a full-text index?
    An index that allows for full-text searches on string columns.
  21. What is a transaction?
    A sequence of one or more SQL operations treated as a single unit.
  22. What are the ACID properties?
    Atomicity, Consistency, Isolation, Durability; they ensure reliable transactions.
  23. What is a rollback?
    A command that undoes changes made in the current transaction.
  24. What is a commit?
    A command that saves all changes made during the current transaction.
  25. What is a savepoint?
    A point within a transaction to which you can later roll back.
  26. What is normalization?
    The process of organizing data to minimize redundancy and dependency.
  27. What are normal forms?
    Guidelines (1NF, 2NF, 3NF, etc.) for structuring databases to reduce redundancy.
  28. What is denormalization?
    The process of combining tables to improve read performance at the cost of redundancy.
  29. What is 1NF?
    First Normal Form; ensures that each column contains atomic values and each entry is unique.
  30. What is 2NF?
    Second Normal Form; removes partial dependencies on a composite primary key.
  31. What is SQL injection?
    A security vulnerability that allows an attacker to interfere with the queries an application makes to a database.
  32. How can you prevent SQL injection?
    Use prepared statements and parameterized queries.
  33. What is user authentication?
    Verifying the identity of a user accessing the database.
  34. What is data encryption?
    The process of converting data into a code to prevent unauthorized access.
  35. What is a stored procedure?
    A precompiled collection of SQL statements stored in the database.
  36. What is a database backup?
    A copy of the database that can be used to restore it in case of data loss.
  37. What is a trigger?
    A set of instructions that automatically executes in response to certain events on a table.
  38. What is a view?
    A virtual table based on the result of a SQL query.
  39. What are stored functions?
    Functions that are stored in the database and can be called from SQL statements.
  40. What is a data warehouse?
    A centralized repository for storing and analyzing large volumes of data.
  41. What is partitioning?
    Dividing a large database table into smaller, more manageable pieces.
  42. What is a NoSQL database?
    A non-relational database that provides flexible data models for unstructured data.

 

 

Scroll to Top