I wonder what would be best in a postgresql database when using primary keys.
IF there is a table with two UUID's columns like user1 and user2, what would be better, to use a constraint key or just define both columns as unique without any primary key, because in postgresql you can only have one primary key in a table?
Example:
CREATE TABLE user_relation(
sender_user_id UUID NOT NULL,
receiver_user_id UUID NOT NULL,
status INT NOT NULL,
chat_id BIGINT,
UNIQUE (chat_id),
CONSTRAINT user_relation_pk UNIQUE(sender_user_id, receiver_user_id)
Or would it be better to just define the both 'primary keys' as unique values like that?
CREATE TABLE user_relation(
sender_user_id UUID NOT NULL,
receiver_user_id UUID NOT NULL,
status INT NOT NULL,
chat_id BIGINT,
UNIQUE (sender_user_id, receiver_user_id, chat_id)
)