Convert an address table to 3NF
SQL
Medium
3 views
Problem Description
CustomerProfile(customer_id, name, city, state, state_code). state_code depends on state. Show 3NF tables.
Output Format
DDL statement(s)
Constraints
Remove transitive dependency
Official Solution
CREATE TABLE States (state VARCHAR(100) PRIMARY KEY, state_code VARCHAR(10) NOT NULL); CREATE TABLE Customers (customer_id INT PRIMARY KEY, name VARCHAR(100), city VARCHAR(100), state VARCHAR(100), FOREIGN KEY (state) REFERENCES States(state));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!