0️⃣ Zero-to-One/Many Relationships, Colors and more!
Valentine’s Day taught us relationships can be rock-solid or a little… optional 💔—and your database is no different! Our latest update lets you define optional or mandatory relationships, customize their colors, and add names to make your diagrams clearer and more meaningful.
Optional or Mandatory Relationships (free plan)
Using the nullable constraint on the foreign key, we can now automatically determine whether a relationship is optional (zero-to-one/many) or mandatory (one-to-one/many) for the parent entity. Take a look at our example below:
Table follows {
following_user_id int [ref: > users.id] // optional, many-to-zero relationship
followed_user_id int [ref: > users.id, null] // optional, many-to-zero relationship
}
Table posts {
id int [pk]
user_id int [ref: > users.id, not null] // mandatory, many-to-one relationship
}
Custom Color for Relationship Lines (paid plan only)
Make your diagrams more readable by assigning custom colors to relationships. You can either pick up a color directly in the diagram or define it via DBML with this syntax:
Ref: posts.user_id > users.id [color: #aabbcc]
If not defined, the relationship line will inherit the parent table’s header color by default.
We’ve also added a flowing animation to show the direction of each relationship.
Named Relationships (free plan)
Label your relationships in DBML and see the names pop up on hover in your diagram! These hover-triggered names make it a breeze to identify connections without cluttering the view.
The syntax for naming a relationship is as follows:
Ref user_posts: posts.user_id > users.id
We hope these enhancements improve your database design and communication experience. Try them out and let us know what you think.