Dynamic tables?

I have a database that has different grades for the course (i.e. three homework for the 1st year, two homework for the course 2, ..., course N with homework M). How should I handle this as the database design goes?

CourseID HW1  HW2 HW3
    1    100  99  100
    2    100  75  NULL

EDIT I guess I need to rephrase my question. At the moment, I have two tables: "Course and homework." Homework points to the course through a foreign key. My question is: how do I know how many homework will be available for each class?

+3
source share
2 answers

. , , .

:

CourseID CourseName
1        Foo

:

HomeworkID HomeworkName HomeworkDescription
HW1        Bar          ...

:

CourseID HomeworkID Result
1        HW1        100
0

, . antipattern, Metadata Tribbles. , - .

, .

Courses Homeworks. Homeworks .

: , ?

, :

SELECT CourseId, COUNT(*) AS Num_HW_Per_Course
FROM Homeworks
GROUP BY CourseId

, , . ( ) .

+2

Source: https://habr.com/ru/post/1766863/


All Articles