When php is writing data, it is called one-to-one and one-to-many. this is a tutorial. this guy tells me that when creating a table, sometimes one table is opposite to another table, sometimes this table needs to work on several tables, that is, one-to-one and one-to-many tables. for the specific reason, this guy will not talk about it, so someone else will talk about it!
What is this secret? what is one-to-one or one-to-many!
I understand that the relationship between tables is not one-to-one. what is one-to-many relationship?
Reply to discussion (solution)
Isn't the instructor and student tables one-to-many?
Isn't the subject table and student table many-to-many?
As for your textures, I don't know English. you didn't explain it. Not easy to say
Isn't the instructor and student tables one-to-many?
Isn't the subject table and student table many-to-many?
As for your textures, I don't know English. you didn't explain it. Not easy to say
What do you mean?
For example:
You have three tables.
Student table (student id student name)
Curriculum (course id course name)
Student id (course id Score)
Class table (class id student id)
Here, the class table and the student table are one-to-one. a class contains many students. in turn, they are multiple-to-one.
The course schedule here is a multi-to-one course. multiple students can select one or more courses.
As for the one-to-one relationship between professors and students, generally one professor corresponds to one student.
Simple
Three tables
Class table
Instructor table
Student table
Link
One class has multiple students
Therefore, the class table and student table are one-to-many.
One teacher has multiple students
Therefore, the instructor and student tables are one-to-many.
One class has multiple teachers
One teacher can teach multiple classes
Therefore, the class table and the instructor table are many-to-many.
Thank you for the two above. But there is still a small question: in this one-to-one, one-to-many, or many-to-many case, how can we see the role in mysql design? Or is there any constraint on this relationship?
Maybe I cannot express it accurately. Specifically, how can these relationships be expressed in SQL statements when writing SQL statements?
A few are your business concepts. they have nothing to do with the database itself and are naturally not reflected in SQL commands.