Answer the question
In order to leave comments, you need to log in
Efficiency of a given relational database structure?
The build uses Laravel 5.4 Eloquent ORM . DBMS = PostgreSQL.
To save space, I created one table of comments, instead of post_comments / video_comments ...
Having registered in the class belongsTo video/post/photo class and in the hasMany classes.
The comment belongs only to the 1st class, post / video / photo.
How effective is such a structure, or do you still need to create posts_comments / videos_comments...?
Answer the question
In order to leave comments, you need to log in
What is the savings?
And here on indexes just you will lose. In this case, you need to do spartial indexes or one (prefix) column under post_id/video_id/photo_id but your orm won't digest it.
Tables like posts_comments or videos_comments are needed for many-to-many relationships,
but one comment cannot belong to several videos or several posts at once, so everything is fine.
Unless you have the opportunity to comment on several posts at once with one comment))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question