ERROR 1005 (HY000) errno: 150 -


i having problem, has been addressed in many posts, none of them show going wrong. error 1005 errno 150 when try following;

structure of appointments:

         create table `appointments` (         `appointmentid` int(11) not null auto_increment,         `apptnum` tinyint(3) unsigned not null default '1',         `cwaid` int(11) not null default '0',         `siteid` int(11) default null,         `titlecode` varchar(25) not null,         `apptpercentage` double default '0',         `status` varchar(2) character set utf8 default null,         `payrate` double default '0',         `ratecode` varchar(5) character set utf8 default null,         `locationinfo` varchar(100) character set utf8 default null,         `apptstartdate` date default null,         `apptenddate` date default null,         `isprimaryappointment` varchar(1) character set utf8 not null            default 'y',         `lastmoddate` timestamp not null default '0000-00-00 00:00:00' on update             current_timestamp,         primary key (`appointmentid`),         unique key `appointmentid` (`appointmentid`),         unique key `cwaid-apptnum` (`cwaid`,`apptnum`),         key `apptnum` (`apptnum`),         key `siteid` (`siteid`),         key `ratecode` (`ratecode`),         key `cwaid` (`cwaid`),         key `titlecode` (`titlecode`),         constraint `fk_employees_appointments` foreign key (`cwaid`) references           `employees` (`cwaid`)         ) engine=innodb default charset=latin1 

structure of jobtitles:

    create table `jobtitles` (       `titlecode` varchar(25) character set utf8 not null,       `jobtitle` varchar(255) character set utf8 not null,       `unitid` varchar(10) character set utf8 not null,       `scope` varchar(10) character set utf8 not null,       `payperiod` char(1) not null default 'm',       `maxpay` decimal(8,2) not null default '0.00',       `minpay` decimal(8,2) not null default '0.00',       primary key (`titlecode`),       key `jobtitle` (`jobtitle`),       key `scope` (`scope`),       key `unitid` (`unitid`)     ) engine=innodb default charset=latin1 

i want add foreign key appointments titlecode field:

     alter table appointments add constraint `fk_jobtitles_appointments`        foreign key (`titlecode`) references `jobtitles` (`titlecode`); 

but attempt generates error 1005 errno 150, implies badly formed foreign key.

any suggestions?


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -