SQL 道场

SQL WORKBENCH

M5 · 难度 4

范式化:拆掉冗余

Browser Postgres · Judge enabled

Prompt

把'订单里重复存客户名'的反范式拆开:建 cust(id 主键、name) 和 ord(id 主键、cust_id 外键 REFERENCES cust(id)、amount 整数)。插入客户 (1,'A')(2,'B');订单 (1,1,100)(2,1,50)(3,2,80)。

SQL Editor

Write, run, inspect, repeat.