Data relationships
Data relationships describe how your data are related to each other. For example:
User
writes manyPosts
.Post
has manyComments
written by differentUsers
.
Direct relationship
A relationship between two data models can be described as follows, depends on the point of view:
- either
Parent Model
hasChild Model
, - or
Child Model
belongs 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):
User
writes manyposts
andPost
has manyusers
. - (indirect relationship):
User
has/receives manycomments
to his posts.
Example 4:
- (direct relationships defined by you):
Post
has manycomments
andcomment
belongs touser
. - (indirect relationship):
Post
has manyusers
(commenters).
How to build
User writes posts and comments in a web forum.
- Add data model:
Post
,Comment
- Add data relationship:
Post
has manyComments