There is a many-to-many relationship between a task table and a user table, and a task table has an one-to-many relationship with a user table, so how can this table be built reasonably?

in a task table, a task can be received by multiple users, and a user can receive multiple tasks, then a user can publish multiple tasks. There is an one-to-many relationship and a many-to-many relationship. So how can this data table be built reasonably? I"d like to ask you for an answer.

Jun.01,2021

three tables, task table, user table, association table, responsible for many-to-many relationship;
add a publisher field to the task table, responsible for one-to-many


this is a many-to-many relationship, establish an intermediate table, and the middle table stores the id


personal suggestion of two tables. In the task table, only the data user table that stores the main task and subtasks is still the user table, and then establish a two-table association table, this table indicates how many tasks a user has. And the associated table should have an index and be of the type of innodb; If you don't want to have a third associated table, you can write a few more lines of task data to the user to whom the task table belongs, ID,. Similarly, the task table is still of type innodb

.
Menu