M
M
maaestr02022-02-06 13:49:55
Database design
maaestr0, 2022-02-06 13:49:55

How to make reviews for articles?

Database for the site: courses, articles, teachers. For each of them, the user can leave a review. You can not make a separate table for reviews for each entity (courses, teachers, articles), but make one: 61ffa6d022e8c047467605.png
That is, course_id and teacher_id = null, then this is a review for the article, if teacher_id and article_id = null, then this is a review for the course and etc.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
vfreelance, 2022-02-06
@maaestr0

difficult option: only two columns are possible: entity id and entity name. example: model_id, model_type and rows in the table will be for example 1; course, 2; course; 3; article. but in a simple way your solution is quite

A
Alexander Nesterov, 2022-02-06
@AlexNest

Let's say you do this.
Suppose I do not like the article, but I do not want to write a canvas of text, and I will limit myself to the word "garbage". How to understand which element the review will refer to?
For each entity, you need to create a separate table.

K
Konstantin Tsvetkov, 2022-02-06
@tsklab

One table: feedback (code, object_type, object_code, text).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question