I am working on creating a simple exam system, in which you are going to be basically able to store students, classes, exams, questions and scores(and some other stuff that those depend on). I am also using Entity Framework code-first.

I am using inheritance for the Student and Instructor classes, which derive from the Person class. In SQL that it represented by a single People table containing a Discriminator column, as well as columns, representing each of the fields of both classes.

Here is a picture of my database diagram:

enter image description here

It is my first time designing a database this complicated and am really not sure if I have done everything right (specifically worried about circular references). I would really appreciate it if you could take a quick look and tell me if you see anything wrong.

Thanks a lot for the answer, mgw854.

The inconsistent naming is because of Entity Framework. I am using code first so it names the columns that it auto-generates(the foreign keys) as it pleases. If you could tell me a how to fix it, I will.

About the Student to Class relationship, it is kinda weird why EF generated it that way. It is probably because I forgot to include a collection of students inside the Class class :D

Also yes, now that I think about it, it definitely would be better if I added a Value column to each question which indicates how many points it gives you and then just use that to calculate the score on runtime.

Thanks for the help. I will fix those ASAP.

PS: I am not going to mark the question as answered, because I want to see some more suggestions, if that's ok with you :)

So I have made the changes and updated the diagram image. Looking for a way to make EF generate column names without underscores without having to write each name manually.

Just found how to fix the naming conventions in a nice way (EF custom naming convention).

Diagram updated again.

1 Answer 1


At first glance, I see lots of inconsistent naming--Person_ID, but PasswordHash (or worse, SchoolYear_ID). Pick a naming convention, and stick with it. I promise you that your future self with thank you!

On your Classes table, you have a Student_ID column. As far as school goes, many students take one class, so class should have a 1:n relationship with students, not a 1:1 relationship. I'd make a Class_Registration table that contains a class id and a student id.

Also, unless your score can be different that what it ought to be based on your performance (say, a professor giving you a boost), you shouldn't have a StudentScores table. That should be derived from the number of questions you answered correctly.

I don't see any worrisome circular references, so I think you're good on that front.

  • I did not find Password_Hash in any picture but only PasswordHash. When I read Person_ID, Password_ID, SchoolYear_ID I cannot find any inconsistencies.
    – miracle173
    Commented Dec 14, 2014 at 23:00
  • 1
    @miracle173, I should have said PasswordHash--that was my mistake. I do, however, find SchoolYear_ID to be an inconsistency--it's both camel case and underscore-separated. It should either be SchoolYearID or School_Year_ID.
    – mgw854
    Commented Dec 14, 2014 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.