forward engineer with mysql workbench cannot create the schema -


-- mysql workbench forward engineering  set @old_unique_checks=@@unique_checks, unique_checks=0; set @old_foreign_key_checks=@@foreign_key_checks, foreign_key_checks=0; set @old_sql_mode=@@sql_mode, sql_mode='traditional,allow_invalid_dates';  -- ----------------------------------------------------- -- schema motivian -- -----------------------------------------------------  -- ----------------------------------------------------- -- schema motivian -- ----------------------------------------------------- create schema if not exists `motivian` default character set utf8 collate utf8_general_ci ; use `motivian` ;  -- ----------------------------------------------------- -- table `motivian`.`user` -- ----------------------------------------------------- drop table if exists `motivian`.`user` ;  create table if not exists `motivian`.`user` (   `user_id` int unsigned not null auto_increment,   `username` varchar(100) not null,   `email` varchar(100) null,   `password` varchar(100) not null,   unique index `username_unique` (`username` asc),   primary key (`user_id`));   -- ----------------------------------------------------- -- table `motivian`.`calculation` -- ----------------------------------------------------- drop table if exists `motivian`.`calculation` ;  create table if not exists `motivian`.`calculation` (   `category_id` int unsigned not null auto_increment,   `calc` varchar(100) not null,   `user_id` int null,   `date_created` timestamp null default current_timestamp on update current_timestamp,   primary key (`category_id`),   constraint `user_id`     foreign key ()     references `motivian`.`user` ()     on delete no action     on update no action);   set sql_mode=@old_sql_mode; set foreign_key_checks=@old_foreign_key_checks; set unique_checks=@old_unique_checks; 

this auto generated mysql workbench constraint not applied. tried this:

constraint user_id foreign key (user_id) referencesmotivian.user(user_id) on delete no action on update no action);

but don't work..... error:

executing sql script in server error: error 1064: have error in sql syntax; check manual corresponds mysql server version right syntax use near ')     references `motivian`.`user` ()     on delete no action     on update no a' @ line 8 sql code:         create table if not exists `motivian`.`calculation` (           `category_id` int unsigned not null auto_increment,           `calc` varchar(100) not null,           `user_id` int null,           `date_created` timestamp null default current_timestamp on update current_timestamp,           primary key (`category_id`),           constraint `user_id`             foreign key ()             references `motivian`.`user` ()             on delete no action             on update no action)  sql script execution finished: statements: 8 succeeded, 1 failed  fetching view definitions in final form. nothing fetch 

your fk definition incomplete. youd did not specify column. select foreign key in table editor , specify column pairs in list right it:

enter image description here


Comments