I am new to the
HAS MANY and
BELONGS TO in the documentation, however I am confused about these features.
Can someone give some real life examples with a diagram that will clear up my doubts?
closed as off topic by Mark Storey-Smith, Paul White♦, Mat, Jon Seigel, Max Vernon Apr 29 '13 at 4:25
Questions on Database Administrators Stack Exchange are expected to relate to database administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.
Suppose you've a blog every blog have some users and posts. Every post belongs to a user. So in that case you can create a relation on user BELONGS TO posts in yii framework.
relation in yii can be defined as :
In case of post every post belongs to a user. So relation looks like this.
Similarly, a user can have multiple posts. So relation for user as:
For reference you can check Working with relations in Yii Framework