I have just started out working on database design and I'm not sure how to write the insert sql uinsg MySQL for this case :
I am trying to create 2 tables with a one-to-many relationship.
Table 1 - tutor
Table 2 - subject
In my table tutor, I have id as the Primary key and it is auto-incremental.
In my subject, I have id as the Primary key and it is auto-incremental, tutorNRIC as the foreign key and tutorNRIC in my tutor table as the reference key.
For my subject, there will be more than one entry in the column tutor_subject.
For example, a tutor will sign up and then all the subjects that she can teach will be entered into that column tutor_subjet.
I'd like to check if my insert sql is correct :
Code: Select all
private final String INSERT_QRY1 = "INSERT INTO hi5project.subject tutor_subject, tutorNRIC VALUES ('?', '?') SET tutorNRIC = hi5project.tutor.tutorNRIC";