One-to-many relationships

One to many relationship is a type of cardinality that refers to a relationship between two entities in an entity relational diagram (between two tables in a database). A simple example would be a binding between the entities order and item. Each order may have multiple items, but a product (e.g., a TV) may be delivered within a single order.

Graphically, a one-to-many relationship is usually represented in a logical model with crow’s foot notation on one side of the relationship.

One-to-many relationship

One-to-many relationships in Moon Modeler

Each time you create a new relationship between tables, a one to many relationship is created.

How to create a new one to many relationship

  • Add two tables to the ER diagram: order and item.
  • Then create a new relationship. On the toolbar, click the Relationship button and first click the order table and then the item table.

Alternate solution – JSON

However, there are more options that may be suitable for similar cases. JSON data types can also be visualized in Moon Modeler. In this case, just create one order table and one JSON document item. In the order table, you can then create a new items column and assign it a JSON document named item as the data type. The graphical representation in the ER diagram is then as follows.

embedded json as alternate solution for one-to-many relationship

The generated SQL script contains the JSON definition.

Types of relationships in ER diagrams

Get started today and try Moon Modeler – ER diagram tool!

Download Read Quick Start Guides