0 Replies - 545 Views - Last Post: 15 June 2017 - 08:26 PM

#1 karengsh  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 132
  • Joined: 18-May 09

How do you insert a third table for many-to-many tables?

Posted 15 June 2017 - 08:26 PM

Dear expert,

I am currently using DAO with plain JDBC to do my project.

I have successfully inserted into my database the first and 2nd table.

e.g INSERT_QRY1 = "INSERT INTO project.subject (subjectName) VALUES (?)"; // the id for this table is auto-incremental

I am stuck as to how do I write the query for the bridging table which consist of Id from table 1 and 2.

The Ids are both auto-incremental so I can't say insert into 3rd table name (subjectId, tutorId) values (?, ?) right ?
cos if I do how am I going to construct the DAO for this 3rd table Id ?
Do I have to create the attribute Id for both tables in order for me to do so?

Hope someone can advise me what to do in this situation. Tks


Is This A Good Question/Topic? 0
  • +

Page 1 of 1