Adding foreign key

I have this structure table, can I ask is it okay to make my column memberid as foreign key to my user table, even it is already set as unique index ?

Thank you in advance.

CREATE TABLE `mytree` (
    `parentid` INT(11) NOT NULL,
    `memberid` INT(11) NOT NULL,
    `position` CHAR(1) NOT NULL COLLATE 'latin1_swedish_ci',
    `amount` DECIMAL(10,2) NOT NULL,
    UNIQUE INDEX `idx_1` (`memberid`),
    UNIQUE INDEX `idx_2` (`parentid`, `position`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
;

If I understand your question correct, then yes that is valid use of a foreign key.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.