5

In a database that have Orders, Customers tables, i need the relation between these two tables to be zero or one to many relationship, simply because in my application, an order can exist without being assigned to a customer.

One first idea that comes to my mind is to make the foreign key nullable, this way when creating an order the foreign key can be null, but i don't know how to do so. I'm working on a model so i can render it to my 'teacher', so i need to know how to do it using the EER diagram.

thanks in advance.

Redaa
  • 1,460
  • 2
  • 16
  • 28

3 Answers3

14

Mandatory option in "Foreign Key" tab in "Relationship" tab appears to be the way to control optionality.

gomi
  • 141
  • 1
  • 3
6

Create your 1:n relationship as normal. Then double click the table to bring up the details. On your new FK field, uncheck the "NN" column. Now your FK can be NULL.

K.A.F.
  • 2,159
  • 1
  • 14
  • 17
  • No. http://stackoverflow.com/questions/762937/whats-the-difference-between-identifying-and-non-identifying-relationships – K.A.F. Aug 01 '14 at 18:31
  • Could you please elaborate? It's ok if the answer is not enough, but a brief explanation can help to move forward with the mysql workbench question. – nilon Jan 17 '20 at 13:23
0

Simply do it this way

  • Right click on the relationship and click on "Edit Relationship"
  • Switch to the "Foreign Key" tab by click on the tabs below the interface
  • Under Reference table section, uncheck the checkbox labeled "Mandatory"

There you go.enter image description here