0
0
Intro to Computingfundamentals~20 mins

Relational database basics in Intro to Computing - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Relational Database Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Primary Keys in Tables

Which of the following best describes the role of a primary key in a relational database table?

AIt uniquely identifies each row in the table.
BIt stores the largest value in a column.
CIt links two unrelated tables without any common data.
DIt is used to encrypt the data in the table.
Attempts:
2 left
💡 Hint

Think about how you would find one unique record among many in a list.

trace
intermediate
2:30remaining
Trace the Result of a JOIN Operation

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;
Intro to Computing
Students table:
ID | Name
1  | Alice
2  | Bob

Enrollments table:
StudentID | Course
1         | Math
1         | Science
2         | History
A
Alice - Math
Alice - Science
Bob - Science
B
Alice - Math
Bob - Science
Bob - History
C
Alice - Math
Alice - Science
Bob - History
D
Alice - History
Bob - Math
Bob - Science
Attempts:
2 left
💡 Hint

Think about matching rows where Students.ID equals Enrollments.StudentID.

identification
advanced
2:00remaining
Identify the Error in a Table Design

Which of the following table designs violates the rules of normalization in relational databases?

AA table with columns for product ID, product name, and price, with product ID as primary key.
BA table with a unique ID column as the primary key and separate columns for first and last names.
CTwo tables linked by a foreign key where one stores orders and the other stores customers.
DA table where multiple phone numbers are stored in a single column separated by commas.
Attempts:
2 left
💡 Hint

Normalization avoids storing multiple values in one column.

Comparison
advanced
2:00remaining
Compare INNER JOIN and LEFT JOIN

What is the main difference between an INNER JOIN and a LEFT JOIN in SQL?

AINNER JOIN returns only matching rows; LEFT JOIN returns all rows from the left table and matching rows from the right.
BINNER JOIN returns all rows from both tables; LEFT JOIN returns only matching rows.
CINNER JOIN returns rows only from the right table; LEFT JOIN returns rows only from the left table.
DINNER JOIN and LEFT JOIN are identical and return the same results.
Attempts:
2 left
💡 Hint

Think about which rows appear when there is no match in the right table.

🚀 Application
expert
3:00remaining
Determine the Number of Rows After a Complex JOIN

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;
A1 row
B3 rows
C2 rows
D4 rows
Attempts:
2 left
💡 Hint

Remember LEFT JOIN returns all rows from the left table, matching rows from the right, or NULL if no match.