Find repeating groups (concept)
SQL
Easy
4 views
Problem Description
Given a table OrdersRaw(order_id, items, quantities) where items are stored like '10|12|14' and quantities '1|2|1', explain why it breaks 1NF in description and give normalized tables in SQL.
Output Format
DDL statement(s)
Sample Test Case
Output:
Normalized design
Constraints
Split multivalued fields
Official Solution
CREATE TABLE Orders (order_id INT PRIMARY KEY); CREATE TABLE OrderItems (order_id INT NOT NULL, product_id INT NOT NULL, qty INT NOT NULL, PRIMARY KEY(order_id, product_id));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!