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.
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
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]
}