DegreeCourse json   -- for which degree programmes this course is appropriate for
    course       CourseId
    degree       StudyDegreeId
    terms        StudyTermsId
    UniqueDegreeCourse course degree terms
Course    -- Information about a single course; contained info is always visible to all users
    name             (CI Text)
    description      Html Maybe    -- user-defined large Html, ought to contain module description
    linkExternal     Text Maybe    -- arbitrary user-defined url for external course page
    shorthand        (CI Text)     -- practical shorthand of course name, used for identification
    term             TermId        -- semester this course is taught
    school           SchoolId
    capacity         Int Maybe   -- number of allowed enrolements, if restricted
    -- canRegisterNow = maybe False (<= currentTime) registerFrom && maybe True (>= currentTime) registerTo
    registerFrom     UTCTime Maybe -- enrolement allowed from a given day onwwards or prohibited
    registerTo       UTCTime Maybe -- enrolement may be prohibited from a given date onwards
    deregisterUntil  UTCTime Maybe -- unenrolement may be prohibited from a given date onwards
    registerSecret   Text Maybe    -- enrolement maybe protected by a simple common passphrase
    materialFree     Bool          -- False: only enrolled users may see course materials not stored in this table
    applicationsRequired       Bool default=false
    applicationsInstructions   Html Maybe
    applicationsText           Bool default=false
    applicationsFiles          UploadMode "default='{\"mode\": \"no-upload\"}'::jsonb"
    applicationsRatingsVisible Bool default=false
    TermSchoolCourseShort  term school shorthand    -- shorthand must be unique within school and semester
    TermSchoolCourseName   term school name         -- name must be unique within school and semester
    deriving Generic

CourseAppInstructionFile
    course    CourseId
    file      FileId
    UniqueCourseAppInstructionFile course file

CourseEdit                -- who edited when a row in table "Course", kept indefinitely (might be replaced by generic Audit Table; like all ...-Edit tables)
    user         UserId
    time         UTCTime
    course       CourseId
CourseFavourite           -- which user accessed which course when, only displayed to user for convenience;
    user         UserId   -- max number of rows kept per user is user-defined by column 'maxFavourites' in table "User"
    time         UTCTime  -- oldest is removed first
    course       CourseId
    UniqueCourseFavourite user course
    deriving Show
Lecturer                       -- course ownership
    user         UserId
    course       CourseId
    type         LecturerType  default='"lecturer"'::jsonb
    UniqueLecturer user course -- note: multiple lecturers per course are allowed, but no duplicated rows in this table
CourseParticipant                      -- course enrolement
    course       CourseId
    user         UserId
    registration UTCTime               -- time of last enrolement for this course
    field        StudyFeaturesId Maybe -- associated degree course, user-defined; required for communicating grades
    allocated    Bool default=false    -- participant was centrally allocated
    UniqueParticipant user course
-- Replace the last two by the following, once an audit log is available
-- CourseUserNote                 -- lecturers of a specific course may share a text note on each enrolled student
--     course       CourseId
--     user         UserId
--     note         Html          -- arbitrary user-defined text; visible only to lecturer of this course
--     time         UTCTime       -- PROBLEM: deleted note has no modification date
--     editor       UserId        -- who edited this note last
--     UniqueCourseUserNote user course
CourseUserNote                 -- lecturers of a specific course may share a text note on each enrolled student
    course       CourseId
    user         UserId
    note         Html          -- arbitrary user-defined text; visible only to lecturer of this course
    UniqueCourseUserNote user course
CourseUserNoteEdit             -- who edited a participants course note when
    user         UserId
    time         UTCTime
    note         CourseUserNoteId -- PROBLEM: deleted notes have no modification date any more

CourseUserExamOfficeOptOut
    course       CourseId
    user         UserId
    school       SchoolId
    UniqueCourseUserExamOfficeOptOut course user school

CourseApplication
    course              CourseId
    user                UserId
    field               StudyFeaturesId Maybe -- associated degree course, user-defined; required for communicating grades
    text                Text            Maybe -- free text entered by user
    ratingVeto          Bool                  default=false
    ratingPoints        ExamGrade       Maybe
    ratingComment       Text            Maybe
    allocation          AllocationId    Maybe
    allocationPriority  Natural         Maybe
    time                UTCTime               default=now()
    ratingTime          UTCTime         Maybe
CourseApplicationFile 
    application         CourseApplicationId
    file                FileId
    UniqueApplicationFile application file