How can I create multiple entries with the same ID in my database? For example in this table named STUDENT
:
STUDID | Name | Training
1 | John Mots | Leadership training
1 | John Mots | Computer Troubleshooting
1 | John Mots | Programming
2 | Marivic | Networking
2 | Marivic | C++ Programming
You have a table which is not in the third normal form. Google normalization for further information.
What you have to do is create a table student
with your student info. Then create a table training
with all your available trainings. Then make a Jointable student_has_training
, with the foreign keys to each of those tables. In that table you can now store which student has which training.
Now if you want the table you showed, you can use (in case of SQL)
Select * from student as 's'
join student_has training as 'st' on s.idstudent = st.student_idstudent
join training as 't' on t.idtraining = st.training_idtraining;