mysql bidirectional composite primary key

Solutions on MaxInterview for mysql bidirectional composite primary key by the best coders in the world

showing results for - "mysql bidirectional composite primary key"
Emily
17 Apr 2018
1CREATE TRIGGER uinsert BEFORE INSERT ON tbl_challenger
2 FOR EACH ROW SET NEW.u0 = LEAST(NEW.host,NEW.challenger),
3  NEW.u1 = GREATEST(NEW.host,NEW.challenger);
4#same for update
5CREATE UNIQUE INDEX uniqueness ON tbl_challenger(u0,u1);
Ambre
18 Jun 2018
1create trigger bi_foo before insert on foo
2for each row
3begin
4  if exists(select 1 from foo where bar1 = NEW.bar2 and bar2 = NEW.bar1)
5  then
6    signal sqlstate '50000' set message_text="Oops";
7  end if;
8end