May I ask the following many-to-many relation: insert data into the intermediate table? There is also the benefit of setting up an intermediate table.

  mysql, question

May I ask the following many-to-many relation: insert data into the intermediate table?
For example, tables user(id1,uname), role(id2,name), ueser_role(id1,di2,);
Can the ueser_role table automatically insert data after the user table and role table insert data?

  • Can consider usingStudio Trigger
  • However, since your insertion may not be successful, to better ensure the consistency of data, you should useTransaction
  • If it is only a one-to-one relationship, why not keep a EAVON table? For example, table user: id/name/id2