Support the ongoing development of Laravel.io →
posted 6 years ago
Eloquent
Last updated 7 months ago.
0
Solution

It's probably one-to-many relationship, as 1 user can have many articles, posts, and comments. But an article or comment will belong only to 1 user. This may be the structure of your db:

users: id | username | password | ...
articles: id | user_id | title | body | ...
comments: id | user_id | article_id | body | ...

Just like user, an article may have one-to-many relationship with comments. An article has many comments but a comment belongs to only one article posted by one user.

Last updated 6 years ago.
0

Sign in to participate in this thread!

Full Stack Europe

Your banner here too?

shigg1120 shigg1120 Joined 16 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.