Is a Composite UNIQUE Constraint On an Already UNIQUE Column Redundant?
1
vote
2
answers
277
views
I'd just like to clarify something pretty simple regarding single and composite
UNIQUE
constraints that I can't find a clear answer to.
Assume I have the following table:
CREATE TABLE person (
id INT PRIMARY KEY,
customer_id INT NOT NULL UNIQUE,
name VARCHAR(20) NOT NULL
...
)
Would it be safe to say that adding the following constraint:
UNIQUE(customer_id, name)
would be redundant and offer no benefit under any circumstance? In other words, is it useless to create a composite UNIQUE
constraint that includes a column which is already UNIQUE
?
This appears to make logical sense, but as I stated, I couldn't find an answer confirming it.
Asked by Twisted Tea
(111 rep)
Sep 5, 2023, 09:25 PM
Last activity: May 21, 2025, 10:05 PM
Last activity: May 21, 2025, 10:05 PM