mysql composite unique on FK's
        Posted  
        
            by m2o
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by m2o
        
        
        
        Published on 2010-04-07T10:05:31Z
        Indexed on 
            2010/04/07
            10:13 UTC
        
        
        Read the original article
        Hit count: 355
        
I want to implement the following constraints in mysql:
create table TypeMapping(
    ...
    constraint unique(server_id,type_id),
    constraint foreign key(server_id) references Server(id),
    constraint foreign key(type_id) references Type(id)
);
This throws a 'ERROR 1062 (23000): Duplicate entry '3-4' for key 'server_id'' when I issue an insert/update that would break the constraint. Is this type of constraint even possible? If so how? Thank you.
© Stack Overflow or respective owner