It is required to implement the connection of table fields so that in the field of the second table we can indicate not one, but several values ​​from the first.

Let's say

(for clarity, I will give examples of the names of tables and cells in Russian)

We have the "People" list:

Fields: id, name

Values:

  1. 1 Vasya
  2. 2 Petya
  3. 3 Sasha
  4. 4 Masha

We also have a table "Parties" with a field "Invited-people" of type set, containing a list of invited people (their id from the table "People").

Let me explain: in the "Invited People" field, only those identifiers that are present in the "People" table should be added.

Question

Is it possible to implement it on mysql?

    1 answer 1

    Are you going to modify the database structure depending on the addition / deletion of users? Use a MANY_MANY link and do not touch the structure.

    users: id, name party: id, name party_users_rel id, user_id (Foreign Key), party_id (Foreign Key) 

    [In both cases, FK is desirable ON DELETE CASCADE]

    • Thank. I am interested in, is it possible to implement this without introducing an additional table? If it is not possible on mysql, is it possible on some other databases? - Getans