6

Lets say I have a table like this:

CREATE TABLE IF NOT EXISTS 
newbook_mast (book_id varchar(15) NOT NULL UNIQUE,          
book_name varchar(50)  ,           
isbn_no varchar(15)  NOT NULL UNIQUE  ,           
cate_id varchar(8)  ,             
aut_id varchar(8) ,             
pub_id varchar(8) ,            
dt_of_pub date ,             
pub_lang varchar(15) ,           
no_page decimal(5,0)            
book_price decimal(8,2) ,             
PRIMARY KEY (book_id)               
);

If I wanted to add a check on a column I would simply write :

CHECK(no_page>0) 

But instead of writing the code I am creating diagram models in the mysql workbench. I am unable to find how I can add a check like above by just using the diagram model?

Is it possible?

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
CodingLittle
  • 1,761
  • 2
  • 17
  • 44

1 Answers1

7

MySQL Workbench as of at least version 8.0.19 does not support CHECK constraints in navigator, table editor, or diagrams.

This has been reported as a missing feature:

https://bugs.mysql.com/bug.php?id=95143 No support for CHECK constraints in Workbench

You should log into the bugs site and click the "Affects Me" button on that bug.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • Well at least i can stopp questioning my eye-sight. Thanks for this! – CodingLittle Apr 08 '20 at 17:58
  • 1
    Has something changed in the last year? still looking for it. – Jenny Apr 02 '21 at 22:59
  • I assume if they had fixed it, then the bug I linked to would be closed, and there would be a comment indicating which version of MySQL Workbench it had been fixed in. – Bill Karwin Apr 02 '21 at 23:25
  • On the other hand, I upgraded to MySQL Workbench 8.0.22 and it seems it now recognizes CHECK constraints. – Bill Karwin Apr 02 '21 at 23:31
  • Yes, the last version recognizes them. But as I can see, there is still no way to implement them "automatically" while creating the eer model diagram, it is necessary to add them manually in the code – Jenny Apr 03 '21 at 08:49
  • Well, as they say, "pull requests welcome." If you want it fixed, write the fix yourself, sign the contributor license agreement, and send them your code. – Bill Karwin Apr 03 '21 at 16:51