Exercise: Database Architecture and Data Storage
Practice and test your understanding of database architecture and data storage.
We'll cover the following...
Time to apply what we’ve learned with some exercises.
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.
Create a simple view named ActiveProducts
that shows ProductID
, ProductName
, and Price
for products that have Stock
greater than 0.
-- Create view ActiveProducts showing in-stock products with ID, name, and price
If you’re stuck, click the “Show Solution” button.
Question 2
Given the following structure of the Orders
table:
Field | Type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Where OrderID
is the primary key and CustomerID
is the foreign key from the Customers
table referring to the customer who placed the order. The table contains information about the orders placed.
Create an index named idx_orders_customer_date
on the Orders
table for the CustomerID
and OrderDate
...