Exercise: Introduction to Database Concepts
Explore fundamental database concepts through practical SQL exercises that cover primary and foreign keys, unique constraints, recursive relationships, and many-to-many table links. Learn to write queries to retrieve and manipulate data across related tables, preparing you for real-world database tasks.
We'll cover the following...
Time to roll up our sleeves and put our knowledge into practice!
Question 1
Given the following structure of the Products table:
Field | Type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Where ProductID is the primary key and CategoryID is the foreign key from the Categories table. The table contains information about products.
Write an SQL query to find the ProductName and Stock for all products in the Products table that have a Price less than $50.00.
If you’re stuck, click the “Show Solution” button.
Question 2
Given the following structure of the Customers table:
Field | Type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Where CustomerID is the primary key and ReferralID is self-referencing to CustomerID. The table ...