Answer the question
In order to leave comments, you need to log in
What is the best way to design a movie model?
Input data (if it matters):
- db: postgres 10
- project: php 7.1 + laravel 5.5 + voyager
Task:
Distribute the movie model into several tables as competently as possible.
- id
- slug (уникален)
- name
- categories (связь с моделью категорий серез 3 таблицу, тут все понятно)
- genres (почти то же самое, что и категории, связь аналогична)
- directors (связь так же через 3 таблицу)
- year
- poster
- excerpt (краткое описание)
- body (описание фильма)
- seo title
- seo keywords
- seo description
seo *
in the film_meta table:- film_id
- seo title
- seo keywords
- seo description
- year
- poster
- excerpt (краткое описание)
- body (описание фильма)
- parent_model_id
- key
- value
Answer the question
In order to leave comments, you need to log in
First you need to study normal forms. Ideally, the table should be in third normal form .
In your case, there is no need to move the attributes from 1) and 2) to separate tables, since they do not violate the requirements of normal forms.
Option 3) is called Entity-attribute-value model , and it is absolutely not needed in this case. Moreover, this is a huge crutch, which can be resorted to only in exceptional cases.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question