CodeStudy.net
Toggle Menu
Home
Online Java Compiler
Tutorials
Java Tutorial
Python Tutorial
SQL Database Design
Blog
All Posts
Joins and Relationships in SQL
Assess how well you understand INNER,LEFT,and RIGHT joins.
1. Which type of join returns only rows with matching values in both tables being joined?
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
2. What type of relationship typically exists between a 'Customers' table (with customer details) and an 'Orders' table (with order records)?
One-to-one
One-to-many
Many-to-many
No relationship
3. Which constraint is used to uniquely identify each record in a table and is often referenced by foreign keys in other tables?
PRIMARY KEY
FOREIGN KEY
UNIQUE
CHECK
4. If you perform a LEFT JOIN between 'Employees' (left) and 'Departments' (right), which rows are included in the result?
Only rows with matching department IDs in both tables
All rows from Employees and matching rows from Departments
All rows from Departments and matching rows from Employees
All rows from both tables, with NULLs where there is no match
5. What is the result of a CROSS JOIN between two tables with 3 and 4 rows, respectively?
3 rows
4 rows
7 rows
12 rows
6. Which of the following are valid types of SQL joins? (Select all that apply)
INNER JOIN
OUTER JOIN
LEFT JOIN
PRIMARY JOIN
7. Which components are required to establish a referential relationship between two tables? (Select all that apply)
Primary Key in the parent table
Foreign Key in the child table
Identical column names in both tables
A UNIQUE constraint in the child table
8. Which of these scenarios would require a junction (link) table to model the relationship? (Select all that apply)
Students and Courses (a student can enroll in many courses; a course can have many students)
Authors and Books (an author writes many books; a book has one author)
Products and Categories (a product belongs to one category; a category has many products)
Actors and Movies (an actor can star in many movies; a movie can have many actors)
9. Which clauses are used to specify join conditions in SQL? (Select all that apply)
ON
WHERE
USING
FROM
10. A FOREIGN KEY constraint in a child table must reference a PRIMARY KEY in the parent table.
True
False
11. A FULL OUTER JOIN returns all rows from both tables, with NULL values in columns where there is no match.
True
False
12. In SQL, you can only join two tables in a single query.
True
False
13. What is the abbreviation for the join that returns all rows from the right table and matching rows from the left table (e.g., 'right ... join')?
14. What term describes a relationship where a record in Table A can relate to at most one record in Table B, and vice versa?
15. In the syntax `SELECT * FROM Orders JOIN Customers ... CustomerID`, what keyword replaces '...' to specify the join condition?
Reset
Answered 0 of 0 — 0 correct