How to create a candidate / super key using MySQL 5.1. I tried in internet, no use. Please help me out...

Its like this. I have tags table. The structure is given below.
Code:
CREATE TABLE `tags` (
    `tid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `cid` INT NOT NULL ,
    `name` VARCHAR( 250 ) NOT NULL
) ENGINE = InnoDB;
I need it to be like this. `tid` is obviously uncontrollable. But no entry should have something like this.

Code:
TID  CID  Name
 1    1   Wordpress
 2    1   Facebook
 3    1   Facebook - This should not come!
I used this code in PHP, but is not working:

Code:
if(mysql_num_rows("SELECT * FROM `tags` WHERE `cid` = ".$lcid." AND `name` = '".$ltag."';") == 0)
    if(mysql_query("INSERT INTO `tags` ( `tid` , `cid` , `name` ) VALUES ( NULL , '".$lcid."', '".trim($ltag)."')"))
        echo '<br>Successfully added '.$ltag.' to '.$_POST['flname'].'.';
    else
        echo '<br>Cannot add '.$ltag.' to '.$_POST['flname'].'. Reason: '.mysql_error();
else
    echo '<br>Cannot add '.$ltag.' to '.$_POST['flname'].'. Reason: Tag already exists!';
Please help me out Shabbir. Thanks

Regards,
Praveen Kumar,
CEO & Managing Director,
PraveenTech Research Labs
Research Labs University
Blog TechVidhya Forums Projects