0
I have a problem that I can not find a solution, I am making a database for a school system, in this system there is the table of materials, which has an ID and a NAME, and teachers who have an ID a NAME and the reference to the materials that they minister.
CREATE TABLE db_materias( id int(4) not null auto_increment, name varchar(20) not null primary key(id) ); CREATE TABLE db_professores( id int(4) not null auto_increment, name varchar(20) not null materias int(4) primary key(id) foreign key(materias) references db_materias(id) );
The problem is, there are occasions when the same teacher ministers multiple subjects, I can make the teacher have a subject but I can not get several, at first I thought about creating an array to store it, but I found that MYSQL has no arrays, I also thought about creating several columns for subjects but I believe that is not the most efficient way to solve. I can’t find anywhere a way to resolve this kind of situation, I’m starting to learn about Databases, I have no experience with the topic. I appreciate the help, thank you.
The usual way to model such a situation (an N:N relationship) is to create another table that relates each teacher to each subject.
– anonimo