Let's say that we create the following table:
CREATE TABLE example (
a integer,
b integer,
c integer,
PRIMARY KEY (a, c)
);
Obviously the compination of a and c has to be unique. But do a and c have to be unique themselves?
Let's say that we create the following table:
CREATE TABLE example (
a integer,
b integer,
c integer,
PRIMARY KEY (a, c)
);
Obviously the compination of a and c has to be unique. But do a and c have to be unique themselves?
No they don't have to be unique separately. Only pairs should be unique.
Example:
a, c
1, 3
2, 3
2, 1
2, 1 -- this will cause unique key violation
INSERT INTO example(a,b,c) VALUES (1,2,3),(2,2,3),(2,3,1);