I have two tables whose data is as follows:
1st Table:
ID NAME GENDER AGE
1 test1 M 18
2 test2 F 20
3 test3 M 18
2nd Table:
ID SubjectCode
1 PHY1
2 PHY2
3 MATH1
I have created another table with 2 foreign keys both being Primary keys of above two tables. It is as follows:
Student_ID Subject_ID
1 PHY1
2 MATH1
1 PHY2
2 PHY2
This third table is created by inserting student id from the table and subject id from 2nd table. But as you can see one student can apply for multiple subjects, and that creates redundancy of student IDs. I am a beginner in SQL and want to convert the third table into 2nd normal form. How do I do it? Which operations should I perform that would help me achieve it?
I was a bit confused regarding 2NF; however, I don't want the IDs in my third table to repeat. I want the IDs to remain unique and the new subject codes corresponding to the same IDs to be included in a different column. I hope I have conveyed what I mean to ask. What do you suggest to achieve it?