MySql Error: #105 (Code 150). When I create my database schema I receive an error code of 150.

前端 未结 1 780
Happy的楠姐
Happy的楠姐 2021-01-20 00:21
DROP SCHEMA IF EXISTS `YouthMinistry` ;
CREATE SCHEMA IF NOT EXISTS `YouthMinistry` DEFAULT CHARACTER SET utf16 COLLATE utf16_general_ci ;
USE `YouthMinistry` ;

--          


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-20 00:56

    You can only create a foreign key on one table that references a key on another table. This specific problem is that memberid is not a key on either groupmembers or rolemembers tables. Simply add KEY (memberid) to those tables and you'll be good to go.

    Another issue us that foreign key types must match. eventgroup has groupid varchar, but is referencing the groups table, which has groupid INT. Correct this.


    As for suggestions, I very strongly recommend that each primary key be only one column: your auto-increment surrogate key. You should make these unsigned integers too.

    0 讨论(0)
提交回复
热议问题