PhpMyAdmin is a query tool for mysql, not a database.
You'll want to make the combination of (Student, Subject) UNIQUE
.
Question
I am to create an enrollment system and I have the following tables in my database:
Subject //Primary key: Subj_no
Student //Primary key: Stdnt_no
Subject_Student //Primary key: Subj_Stdnt_no
Where Subject_Student is related(indexed) to Subject and Student with their primary keys.
Now my question is: How can I prevent the database from making the same relationship again? Example> For say I have the following rows inside Subject_Student:
Subj_Stdnt_no | Subject | Student
1 | 1 | 2
2 | 1 | 6
3 | 1 | 2 <------How can I prevent that? It's redundant.
Solution
PhpMyAdmin is a query tool for mysql, not a database.
You'll want to make the combination of (Student, Subject) UNIQUE
.
OTHER TIPS
I've managed to answer my own question through thew help of @Femaref I used: ALTER TABLE Subject_Student ADD UNIQUE (Subject,Student);