Support zero/optional relationship in DBML

Right now it is not possible to visualize whether a relationship is mandatory or optional. As these options are very common, this feature would allow us to create more detailed and complete schema diagrams.

For example, to show that details are optional for an order, we could include a new symbol “0>”:

Table order_detail {
  orderId int [ref: 0> order.orderId]
  detailDescription varchar
}

With this, we communicate an order may have 0 or many order_details, but every order_detail must only relate to one order.
order_detail >0------|| order

To show that the other side is optional we could put the 0 on the other side of the operator “>0”.

I just discovered dbdiagram and love it! The lack of optional relationships is a big drawback. If we are unable to document cardinality then it greatly reduces the value that dbdiagram provides

2 Likes

Is there an update on this?

cheers

Cyrill

Hi, @Cyrill_Jorg ,

I’m Huy Le from the dbdiagram team.

This functionality is already in our backlog. We will consider implementing it in the future, also will notify you if there are any updates.

Thanks!

The lack of this feature prevents me from purchasing the team plan.

1 Like

Hi @david-oc-miller,

I’m Nguyen from the dbdiagram team.

We are working on this feature. We will notify you if there are any new updates.

Regards.

Any update? I really need this feature.

Update March 2025: This feature was recently released. You can now test it by defining a relationship with and without nullability for the foreign key. For instance:

Table follows {
  following_user_id int [ref: > users.id] // optional relationship
  followed_user_id int [ref: > users.id] // optional relationship
}

Table posts {
  id int [pk]
  user_id int [ref: > users.id, not null] // mandatory relationship
}

Table users { 
  id int [pk]
}

The outcome will be as follows:

1 Like