Using set with values ​​from a table

I am writing a database of all the DVDs that I have at home. One of the fields actors, I would like it to be a set of values ​​from another table in which the actors are stored. Therefore, for each film I want to keep a list of actors, all of which are selected from the list of actors taken from another table.

Is it possible? How should I do it? This will be a set of foreign keys in the main.

I am using a MySQL database for a Django (python) application, so any hint of SQL or Python would be greatly appreciated.

I hope the question is clear, thank you very much.

+3
source share
2 answers

Make your tables like this:

Movies
MovieID   int auto increment/identity PK
MovieTitle
MovieDescription
etc...

Actors
ActorID  int auto increment/identity PK
ActorName
DateOfBirth
etc...

MovieActors
MovieID      PK  and FK
ActorID      PK  and FK
RoleName
etc...

"", MovieActors.

, . , , , X.

+2

. , movies_actors. , . " ".

+1

Source: https://habr.com/ru/post/1739874/


All Articles