Which of the following best describes the role of a primary key in a relational database table?
Think about how you would find one unique record among many in a list.
A primary key is a unique identifier for each row in a table, ensuring no two rows have the same key value.
Given two tables, Students and Enrollments, what will be the result of the following SQL query?
SELECT Students.Name, Enrollments.Course FROM Students JOIN Enrollments ON Students.ID = Enrollments.StudentID;
Students table: ID | Name 1 | Alice 2 | Bob Enrollments table: StudentID | Course 1 | Math 1 | Science 2 | History
Think about matching rows where Students.ID equals Enrollments.StudentID.
The JOIN matches each student with their enrolled courses by matching IDs, producing one row per matching pair.
Which of the following table designs violates the rules of normalization in relational databases?
Normalization avoids storing multiple values in one column.
Storing multiple values in one column breaks the first normal form, which requires atomic (single) values per field.
What is the main difference between an INNER JOIN and a LEFT JOIN in SQL?
Think about which rows appear when there is no match in the right table.
INNER JOIN returns rows where there is a match in both tables. LEFT JOIN returns all rows from the left table, with NULLs for unmatched right table rows.
Consider these two tables:
Authors: ID | Name 1 | Jane 2 | Mark Books: ID | Title | AuthorID 1 | Book A | 1 2 | Book B | 1 3 | Book C | 3
What is the number of rows returned by this SQL query?
SELECT Authors.Name, Books.Title FROM Authors LEFT JOIN Books ON Authors.ID = Books.AuthorID;
Remember LEFT JOIN returns all rows from the left table, matching rows from the right, or NULL if no match.
Jane has two books, so two rows; Mark has no books, so one row with NULL for book title; total 3 rows.