M
M
mShpakov2018-04-21 19:52:22
PostgreSQL
mShpakov, 2018-04-21 19:52:22

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.

Model:
- id
- slug (уникален)
- name
- categories (связь с моделью категорий серез 3 таблицу, тут все понятно)
- genres (почти то же самое, что и категории, связь аналогична)
- directors (связь так же через 3 таблицу)
- year 
- poster
- excerpt (краткое описание)
- body (описание фильма)
- seo title
- seo keywords
- seo description

Questions:
1) I think to put the properties seo *in the film_meta table:
- film_id
- seo title
- seo keywords
- seo description

Is it right?
2) Where to put these properties? Or is it normal practice to store them in the same table?
- year 
- poster
- excerpt (краткое описание)
- body (описание фильма)

PS
I met somewhere like this:
- parent_model_id
- key
- value

But I don't think it's very convenient or correct.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2018-04-22
@mShpakov

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.

Y
Yuri, 2018-04-22
@kapitan7830

1, 2 - I would leave it in the main table, you won't have several SEO titles or release years for one movie, but categories, etc. would generally remove and register the relationship in the 3rd table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question