Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type-based database design

I want to rate (Very Good, Good, Medium, Bad...) 2 objects: Student and Teacher. Which design solution is better?

Solution 1:

Students(StudentID, Rating,...)

-----------------1--------Good-----

-----------------2--------Bad-----

-----------------3-----Very Good-----


Teachers(TeacherID, Rating,...)

-----------------1-----Very Good-----

-----------------2--------Bad-----

-----------------3--------Bad-----

Solution 2:

Students(StudentID, RatingTypeID,...)

-----------------1----------------2----------

-----------------2----------------1----------

-----------------3----------------3----------


Teachers(TeacherID, RatingTypeID,...)

-----------------1----------------1----------

-----------------2----------------1----------

-----------------3----------------3----------


RatingType(RatingID, RatingDescription,...)

-----------------1-------------Very Good---------

-----------------2---------------Good--------------

-----------------3----------------Bad---------------


If both of them are not good enough, can you give me some suggestions? Thanks!

like image 399
Jack Cood Avatar asked Jul 25 '26 19:07

Jack Cood


1 Answers

Solution 2 is the best from those two, but if You want to have multiple votes in the course of your application's life, you should have a table where you identify what is the subject of the vote, and another where you store the votes:

Student:
   id
   name
   class
   ...

Teacher:
   id
   name
   subject
   ...

voterType
   id 
   description (student or teacher)

contest:
   id
   description (ex: 1st Semester 2013)

contestVotes:
   id
   contestId
   voterType (Teacher or Student)
   voterId
   ratingTypeId
like image 88
Filipe Silva Avatar answered Jul 27 '26 10:07

Filipe Silva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!