1st Table = Student [s_id is pk ]
2nd table = Teacher[t_id is pk , s_id is f_k] here i want to create composite key[comp_id] combining (t_id[pk] + s_id[f_k])
and that composite key use as foreign key to collage table
3rd table= collage[col_id is pk, comp_id as f_k ]
how to do in using J_PA repository and spring boot m_v_c
That design would make your Teacher
table Many-to-many, which you should normalise like so:
CREATE TABLE #Student
(
id INT -- student
)
CREATE TABLE #Teacher
(
id INT -- teacher
)
CREATE TABLE #TeacherStudent
(
id INT, -- optional
t_id INT, -- teacher
s_id INT -- student
)
You could create an id
on the TeacherStudent
table or create a composite key from the other id's you have in that table.