I am trying to develop a structure in the following manner…
- I am representing Courses which are taught by Teachers.
- For each of those Courses there are any number of Exams (because the Exam is randomly generated, each generation counts as a different exam), and I have to track that in the database.
- An Exam can be taken by 0 or more Students. (And, conversely, a Student can have taken one or more Exams.)
- Once the Student takes the exam (which is done via a web interface that I have already developed), that Student receives a score for the Exam and an ExamStatus (Passed, Failed, Retake, TestOut, etc.)
- There are some other “stuff” in there that I didn’t address such as Exams are made up of Questions (which are created by the Teacher), etc, but I have a good understanding of that.
I have almost finished my structure, but I am struggling with how to represent the relationship of Students to Exams and also working the ExamStatus. Here is my thought so far. (It is late, so my apologies for stupid errors.)
public class Student
{
public string StudentID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
// Should this even be part of the Student POCO?
public virtual ICollection<Exam> ExamsTaken { get; set; }
}
// I know this is right - putting it here to provide all the classes in question.
public class ExamStatus
{
public int ExamStatusID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
// This is the POCO that really hangs me up.
public class Exam
{
public int ExamID { get; set; }
public int CourseID { get; set; }
public string ExamTitle { get; set; }
// Not sure if this should be part of Exam, or part of a different
// object?
public decimal? Score { get; set; }
public int? ExamStatusID { get; set; }
public virtual ICollection<Question> Questions { get; set; }
public virtual Course Course { get; set; }
public virtual ExamStatus ExamStatus { get; set; }
}
I would appreciate any help with this many-to-many relationship (Students <-> Exams). I think I’ve thought about it too much and have thoroughly confused myself on something that is probably fairly straightforward.
This is what I would change. I don’t THINK its exactly what Adam said. If it is let me know and i’ll remove the post