Data relationships
Data relationships describe how your data are related to each other. For example:
Userwrites manyPosts.Posthas manyCommentswritten by differentUsers.
Direct relationship
A relationship between two data models can be described as follows, depends on the point of view:
- either
Parent ModelhasChild Model, - or
Child Modelbelongs toParent Model
Example 1:
User writes posts in a web forum.
Example 2:
User writes posts and comments.
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):
Userwrites manypostsandPosthas manyusers. - (indirect relationship):
Userhas/receives manycommentsto his posts.
Example 4:
- (direct relationships defined by you):
Posthas manycommentsandcommentbelongs touser. - (indirect relationship):
Posthas manyusers(commenters).
How to build
User writes posts and comments in a web forum.
- Add data model:
Post,Comment - Add data relationship:
Posthas manyComments