> ...when I try to apply more than 1 competency to a student
This hints a one-to-many relationship (one student to many competencies)
to begin with, but there is actually more to it...
> ...otherwise I have to have a separate field for each competency
No, no, no and no! This is absolutely wrong!
Actually, you are dealing with a many-to-many relationship here; a
student may (hopefully) possess several competencies, while each
competence may be (hopefully) possessed by several students. In a
relational database design, many-to-many relationships are implemented
by means of an intermediate table (commonly called a junction table,
among other names) which splits it into two one-to-many relationships,
by introducing an artificial "entity", being a unique combination of one
member of each of the two "sides" of the original many-to-many; in your
case, a StudentCompetence. So, in your example you need:
A students table, like:
tblStudents
StID (Primary Key)
FIrstName
LastName
DOB
(etc)
A competencies table, like:
tblCompetences
CmpID (Primary Key)
Competence
(etc)
And a stbStudentCompetencies (junction) table, like:
tblStudentCompetences
StID (Foreign Key)
CmpID (Foreign Key)
Where the two foreign key fields together are also defined as the
junction table's (composite) Primary Key, so it guarantees uniqueness
(among other things).
HTH,
Nikos
|