runtime
59 / 139

task Constraints · hard

Enforce delivery-slot rules

Create delivery_slots with slot_id INTEGER PRIMARY KEY, warehouse_id INTEGER NOT NULL referencing warehouses(warehouse_id), slot_date TEXT NOT NULL that must be a valid YYYY-MM-DD date, capacity INTEGER NOT NULL between 1 and 500, and at most one slot per warehouse and date. Insert (1, 1, '2025-05-01', 120) and (2, 1, '2025-05-02', 80). Return slot_id, warehouse_id, slot_date and capacity.

what to return

Columns
slot_idwarehouse_idslot_datecapacity in this order
Rows
2 rows · any order
Skill
Encode business rules as constraints. Refresher: Constraints protect the data contract →

expected result

expected result2 rows · any order
slot_idwarehouse_idslot_datecapacity
112025-05-01120
212025-05-0280

all 2 rows

data you can query

warehouses6 columns · 38 rows
warehouse_idnumber · unique idwarehouse_codetextfacility_typetextcitytextstatetextopened_atdate
1FOH1fulfillmentColumbusOH2017-04-19
2FTX2fulfillmentDallasTX2017-03-17
3FCA3fulfillmentSacramentoCA2016-02-04
4FNJ4fulfillmentNewarkNJ2018-11-23
5FGA5fulfillmentAtlantaGA2019-07-04
6FIL6fulfillmentChicagoIL2016-03-21
7SOH7sortationColumbusOH2016-04-05
8STN8sortationMemphisTN2022-02-11
9STX9sortationDallasTX2023-06-25
10SGA10sortationAtlantaGA2019-01-10
warehouse_idnumber · unique id
1
warehouse_codetext
FOH1
facility_typetext
fulfillment
citytext
Columbus
statetext
OH
opened_atdate
2017-04-19
warehouse_idnumber · unique id
2
warehouse_codetext
FTX2
facility_typetext
fulfillment
citytext
Dallas
statetext
TX
opened_atdate
2017-03-17
warehouse_idnumber · unique id
3
warehouse_codetext
FCA3
facility_typetext
fulfillment
citytext
Sacramento
statetext
CA
opened_atdate
2016-02-04
warehouse_idnumber · unique id
4
warehouse_codetext
FNJ4
facility_typetext
fulfillment
citytext
Newark
statetext
NJ
opened_atdate
2018-11-23
warehouse_idnumber · unique id
5
warehouse_codetext
FGA5
facility_typetext
fulfillment
citytext
Atlanta
statetext
GA
opened_atdate
2019-07-04
warehouse_idnumber · unique id
6
warehouse_codetext
FIL6
facility_typetext
fulfillment
citytext
Chicago
statetext
IL
opened_atdate
2016-03-21
warehouse_idnumber · unique id
7
warehouse_codetext
SOH7
facility_typetext
sortation
citytext
Columbus
statetext
OH
opened_atdate
2016-04-05
warehouse_idnumber · unique id
8
warehouse_codetext
STN8
facility_typetext
sortation
citytext
Memphis
statetext
TN
opened_atdate
2022-02-11
warehouse_idnumber · unique id
9
warehouse_codetext
STX9
facility_typetext
sortation
citytext
Dallas
statetext
TX
opened_atdate
2023-06-25
warehouse_idnumber · unique id
10
warehouse_codetext
SGA10
facility_typetext
sortation
citytext
Atlanta
statetext
GA
opened_atdate
2019-01-10

first 10 of 38 rows · your queries use all of them

solution.sql
 
Output

Hints and the answer are always available. Using them counts the question as solved with help.

Enforce delivery-slot rules — SQL practice · Runtime