Strengthen your SQL interview preparation with this quiz covering fundamental questions about SQL usage, data management, keys, constraints, and relational database principles. Each question is crafted to help you master the essential SQL concepts expected in 2025 job interviews for roles like data analyst, developer, and engineer.
Which of the following best describes a key distinction between a DBMS (Database Management System) and an RDBMS (Relational Database Management System)?
Explanation: The main difference is that an RDBMS supports relationships between tables using keys, whereas a DBMS manages data as isolated files without enforcing relationships. Option A is incorrect because 'flat files' describe traditional DBMS, not RDBMS. Option B reverses their functions. Option D is incorrect since RDBMS emphasizes unique keys more than DBMS does.
In a classroom database table containing columns for name, address, phone, and roll number, which column would be the most appropriate to designate as the primary key?
Explanation: The roll number uniquely identifies each student, making it the ideal choice for a primary key. Names and addresses can repeat among students, so they cannot guarantee uniqueness. Though phone numbers are often unique, some may be shared or missing, making them unreliable. Roll numbers never duplicate and help ensure data accuracy.
When connecting a ‘Students’ table with a ‘Courses’ table in a database, what purpose does a foreign key serve?
Explanation: A foreign key links two tables, allowing data in one table to reference related data in another, such as linking students to the courses they take. Option A is incorrect as foreign keys do not create tables. Option B describes a primary key, not a foreign key. Option D is not accurate since foreign keys don't prevent duplicates by themselves.
If a column in a SQL table is defined with the NOT NULL constraint, which rule does it enforce for data entry in that column?
Explanation: The NOT NULL constraint ensures that a column cannot have missing or empty values, requiring data in every row. Option A describes the UNIQUE constraint. Option B is not enforced by NOT NULL but could be checked with other constraints. Option D is unrelated, as NOT NULL does not auto-generate values.
Why would you use the UNIQUE constraint on an email column in a user table?
Explanation: The UNIQUE constraint stops duplicate values from being entered in the specified column, ensuring each user's email is distinct. Option B refers to NOT NULL, not UNIQUE. Option C is about foreign keys, and Option D is unrelated since case sensitivity is not enforced by UNIQUE.
Which property must every primary key have in a relational database?
Explanation: A primary key requires that each value be unique and not NULL, ensuring correct identification of rows. Option A is incorrect because duplicates are not allowed. Option B refers to foreign keys, not primary keys. Option D is incorrect, as a primary key can consist of one or more columns, but it's not mandatory to have multiple columns.
What is a significant advantage of using an RDBMS when managing large sets of student records?
Explanation: An RDBMS enables efficient querying and retrieval of related data across different tables, which is especially helpful with large datasets. Option A is not a benefit, as organized data is preferable to scattered data. Option C is incorrect since RDBMS supports multiple user access. Option D is false; handling large data is a strength of RDBMS.
In a database form, if you want to ensure that entered ages are only between 18 and 60 years, which SQL feature or constraint should you use?
Explanation: The CHECK constraint is used for enforcing rules about the values in a column, such as limiting age inputs to a certain range. UNIQUE only requires that values be different, not that they're within a range. PRIMARY KEY is for unique identification, and DEFAULT specifies a value to use if none is provided—not a range.
How does an RDBMS support multiple users working with the same data at the same time?
Explanation: RDBMS systems allow multiple users to safely work on data at once using features designed to prevent conflicts and preserve data integrity. Option A is not correct; RDBMS is designed for multi-user environments. Option C would make data less secure and is not best practice. Option D does not describe how modern RDBMS store data.
Which feature of an RDBMS helps to reduce data redundancy within a student information system?
Explanation: Primary and foreign keys allow tables to be related, which ensures each piece of data is stored only once and referenced as needed, reducing redundancy. Option A increases redundancy because data is repeated. Option C is incorrect, as duplicate records are a form of redundancy. Option D could compromise data structure and control.