Data relationships

Data relationships describe how your data are related to each other. For example:

  • User writes many Posts.
  • Post has many Comments written by different Users.

Direct relationship

A relationship between two data models can be described as follows, depends on the point of view:

  • either Parent Model has Child Model,
  • or Child Model belongs to Parent Model
graph LR; P(Parent Model) --> |has| C(Child Model);
graph RL; C(Child Model) --> |belongs to| P(Parent Model);

Example 1:

User writes posts in a web forum.

graph LR; User -- has many --> Post;
graph RL; Post -- belongs to --> User;

Example 2:

User writes posts and comments.

graph LR; User -- has many --> Post; Post -- has many --> Comment; User -- has many --> Comment;
graph RL; Post -- belongs to --> User; Comment -- belongs to --> Post; Comment -- belongs to --> User;

A data relationship is bi-directionally. You just define one direction and the inverse direction will be created and maintained for you automatically.

For example: If you define “User has many Post” on the User side and then goto the Post model, you will see “Post belongs to User”, without manually creating it.

Indirect relationship

While you define the direct relationship between your data models, we analyse them and build indirect relationships for you automatically.

Indirectly relationship is one of the powerful tools allows you to build a complex app without coding.

Example 3:

  • (direct relationships defined by you): User writes many posts and Post has many users.
  • (indirect relationship): User has/receives many comments to his posts.
graph LR; User -- has many --> Post; Post -- has many --> Comment; User -. "has/receives many comments".-> Comment;

Example 4:

  • (direct relationships defined by you): Post has many comments and comment belongs to user.
  • (indirect relationship): Post has many users (commenters).
graph LR; Post -- has many --> Comment; Comment -- belongs to --> User; Post -. "has many (Commenter)" .-> User

How to build

User writes posts and comments in a web forum.

  1. Add data model: Post, Comment
  2. Add data relationship: Post has many Comments
Add new data model
Post and Comment added
Add data relationship: Post has Comments
Data relationships added