1

I am designing the database for an application for tv series and movies. As I was studying the data that will have to be saved, I noticed that films, tv series, tv series seasons and tv series episodes have very similar data.

All of them have a title, air date, cast list, crew list, composers, director list, description, soundtrack, rate, rating, icon (or images), views, trailers, genres etc. It can be said that all of them also have a type (some variable that determines whether it is a season, film, tv series or episode).

There are some differences (ex. a film and an episode have streams, while tv series and seasons don't). There could be more differences in the future, but especially films and episodes seem very similar.

I was considering that maybe it makes sense to store all this information in the same table. The type would tell me what kind of item this is. Episodes would have a season identifier and a tv series identifier. Seasons would have a tv series identifier, to travel back and forth between tv serie - season - episode. Seasons and episodes also will need a number (season number, episode number).

There are obviously other tables, like the genre table, the stream table etc.

On the other hand, querying for certain information with such a design can get complex. For example, if I want to list all tv series with a certain number of episodes or the tv series whose episode streams are stored on a particular CDN (in this application it will be necessary), I would either have to make separate queries, or use subqueries. There are many other cases where keeping all 4 item types seems to complicate things. Since I have to use sequelize (node js ORM) instead of raw queries, I know from previous experience that it will lead to messy code and bad performance.

Would it be bad design or breaking entity integrity if I separated the items in different tables?

4

1 回答 1

0

据我所知,在同一个表中列出常用列也是一种很好的做法。假设将来有一个新列,这很常见,如 production_house 等。那么您不需要在所有表中添加新列。

希望,我正确理解你的问题。

于 2018-07-16T13:48:41.877 回答