Lab 2 of 32 · 40 min · Intermediate · Objective 1.2
Create, read, update and delete inventory data in transactions
Scenario
Marlow Creek Supply distributes hardware from three warehouses: Dallas (DAL), Phoenix (PHX) and Kansas City (KCY). Its inventory database holds products (each SKU with its category, price and reorder point), stock (the quantity of each SKU in each warehouse), and the stock_transfers and receipts logs. A foreign key ties every stock row to its product, and a CHECK keeps every quantity at 0 or more.
You are the DBA on duty, and the morning's tickets are all changes to this data: create, read, update and delete, and two jobs that must happen completely or not at all. The snapshot schema holds last night's copy of products and stock for the reconciliation report: leave it as it is.
This is PostgreSQL itself, running in your browser tab, in autocommit mode: each statement is committed as soon as it runs unless you open a transaction with BEGIN. \dt lists the tables, \d stock describes one, and Reset database builds everything again as it was this morning. (The checks run through a function of their own, in the lab_checks schema.)
Tasks
0 of 7 tasks done
Purchasing asks which products the Dallas warehouse needs to reorder: those we still sell (not
discontinued) whoseqtyat DAL is at or below theirreorder_point. Showsku,nameand the DALqty, the lowest quantity first, then bysku.
Your work is checked each time you run a statement.
The database is built fresh each time you open the lab. A lab you completed stays completed. The database is PostgreSQL itself (PGlite: PostgreSQL compiled to WebAssembly), running inside this tab and connected to nothing. Licenses