Implementing 2 keys table in sql Considering this table >
TRIP Table :
( Code [pk] , Origin , Destination , Distance )
how to make (Origin , Destination) attributes has the constraint of composite key "can repeat if one of them is different" .
Not sure where there complexity is. Use a UNIQUE constraint on a composite key.

CREATE TABLE foo (
  a int,
  b int,
  UNIQUE(a,b)
);
INSERT INTO foo VALUES (1, null), (2, null);
INSERT INTO foo VALUES (null,1), (null,2);


But, 

INSERT INTO foo VALUES (2,2), (2,2);
ERROR:  duplicate key value violates unique constraint "foo_a_b_key"
DETAIL:  Key (a, b)=(2, 2) already exists.


If you're not creating the table but modifying one already made, you can use this:

ALTER TABLE foo ADD CONSTRAINT foobar UNIQUE (a, b);