...

/

Exercise: Introduction to Database Concepts

Exercise: Introduction to Database Concepts

Test your understanding of fundamental database concepts.

Time to roll up our sleeves and put our knowledge into practice!

Question 1

Given the following structure of the Products table:

Field

Type

ProductID

int

ProductName

varchar(50)

CategoryID

int

Price

decimal(10,2)

Stock

int

LastRestockDate

date

MonthlySales

int

InventoryTurnoverRate

decimal(5,2)

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.

Press + to interact
MySQL 8.0
-- Select the product name and stock for products priced under $50

If you’re stuck, click the “Show Solution” button.

Question 2

Given the following structure of the Customers table:

Field

Type

CustomerID

int

CustomerName

varchar(50)

Email

varchar(50)

Phone

varchar(15)

Address

varchar(100)

LastLogin

date

CreatedAt

timestamp

CustomerTier

enum('New','Regular','VIP')

ReferralID

int

LoyaltyPoints

int

LastPurchaseDate

date

IsChurnRisk

tinyint(1)

Where CustomerID is the primary key and ReferralID is self-referencing to CustomerID. The table contains information about customers. ...