db engine changed to innodb, foreign key bugs fixed