简体   繁体   中英

Complex DB tables problem

I am developing a student results website in which :-

  1. Every year has its own subjects ( 1st year has sub1 , sub2 , sub3 and 2nd year other subjects and so on ) which will be added , deleted by the admin of the site .

I designed three tables :-

  1. "Students" : contains info about students and their current year .
  2. "Subjects" : info about subjects .
  3. "Years" : info about years in the school .
  4. "Years_Subjects" : relation between the years and its subjects .

The problem now is How can i store a result ?? how can i design the results table to contain degrees for different subjects ???

Thanks

Results will be a table that has the following values (results) and the following foreign keys Student, Subject, (possibly year)

Have a degrees table and an association table between subject and degree

Results  -> Student
         -> Subject
         -> Year?

Degree  <- DegreeSubject -> Subject

I think you want a Results table like this.

Results
--------
Student_ID (FK to Students)
Years_Subjects_ID (FK to Years_Subjects)
Score

I don't think it would be best to have a FK to Years and another FK to Subjects, because you won't be able to easily prevent a row that represents a subject that was not offered in a particular year.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM