B
B
BonBon Slick2017-02-23 00:29:57
Database
BonBon Slick, 2017-02-23 00:29:57

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 ...
f6RC5NWpSD0.jpg
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

2 answer(s)
L
lega, 2017-02-23
@BonBonSlick

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.

E
Ernest Faizullin, 2017-02-23
@erniesto77

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 question

Ask a Question

731 491 924 answers to any question