Hi,
I'm trying to create a table with 2 columns both are primary key
(combined) and both are foreign key as well. I'm getting error cannot
create table. Here is the sql

CREATE TABLE `userroles` (
        `roleid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
        `userid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
        PRIMARY KEY (`roleid`, `userid`),
        INDEX `FK1_user` (`userid`),
        CONSTRAINT `fk_userid` FOREIGN KEY (`userid`) REFERENCES `users`
(`userid`) ON UPDATE CASCADE ON DELETE CASCADE,
        CONSTRAINT `fk_roleid` FOREIGN KEY (`roleid`) REFERENCES `roles`
(`roleid`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE=utf8_general_ci
ENGINE=InnoDB
ROW_FORMAT=COMPACT
AVG_ROW_LENGTH=0

-- 
Sharique uddin Ahmed Farooqui
(C++/C# Developer, IT Consultant)
http://safknw.blogspot.com/
"Peace" is the Ultimate thing we want.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to