Does MySQL Workbench require a link field that cannot be NULL?

I am developing a database, and I am wondering if the mandatory checkbox in the mysql workbench tool has this field should be zero or required in this situation?

Later, if necessary, I will include an image of this table where this question arose.

Tanks to the rescue.

UPD:
I must say that after I generated the SQL models and looked at both tables, I did not see anything else. I'm starting to think that this required parameter is displayed only visually, but in a functional way it does not mean anything.

If I'm wrong, please help. Tanks again.

+7
source share
3 answers

I came to the conclusion that this is just a visual effect to show that relationships are mandatory. This parameter has no effect on the generated SQL code.

+2
source

Ok, I found it.

Let's say you have one table named User and the second is called Address , and you want to establish a relationship between them. An example might look like this:

User
id
Name

Address
id
user_id
street

So you have a foreign key in Address for User . If you make this relationship, all fields are required, so user_id is the primary key field, it is not null, and Address - id is the same, but what is Address - user_id ? Is this part of the primary key in Address ? No, this does not help you determine the row in this table. Thus, Address - user_id may be null, perhaps you received only Address , and the Address table is even indicated by the table company.

The fact is that the mandatory checkbox in the "Reference Table" is only for visual effects, opposite the checkbox in the "Linked Table" -side makes the field null or not.

If necessary, the Address-user_id field can never be null. If this is not necessary, the field may be empty for one row of data, and there will be no restrictions.

+8
source

Most likely, this means that the field value cannot be NULL . I say most likely because I cannot find the β€œrequired” word anywhere in the MySQL Workbench here.

0
source

All Articles