Answer the question
In order to leave comments, you need to log in
What data type should be used in sql to indicate genres for example?
If I want to put several different values in 'genres' - action, thriller, drama, etc.
Answer the question
In order to leave comments, you need to log in
integer:
create table genres (
id int primary key auto_increment,
name varchar(255)
);
create table films (
id int primary key auto_increment,
name varchar(255)
);
create table film_genres (
film_id int,
genre_id int
);
Look here .
Potentially not too much data to worry about the size of both the movie table and the genre table.
In Postgresql, you can make an array of enams.
True, I xs how it will be with indexing.
The most common option is to make a table with genres and make a Many-to-Many relationship between it and the table with movies. It will be just another intermediate table with movie ID and genre ID.
Slava Rozhnev gave a code example for such a case..
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question