Hi,
I have 2 tables with many to many relation:
student
(
id int(11) NOT NULL,
name varchar(255),
primary key(id)
);
teacher
(
id int(11) NOT NULL,
name varchar(255),
primary key(id)
);
and I should do 3 table - student_has_teacher
option add id separate field primary key
student_has_teacher ( id int(11) NOT NULL, teacher_id int(11), student_id int(11) primary key(id) );
option make 2 fields primary key
student_has_teacher ( teacher_id int(11), student_id int(11), primary key(teacher_id,student_id), foreign key(teacher_id) references teacher(id), foreign key(student_id) references student(id) );
What is better option and why?
Thanks