How can I make a schedule table for instructor from tables created

痴心易碎 提交于 2019-12-02 13:03:26

A table for this report

This report only works if 'Michel' identifies one instructor. Otherwise either you need multiple sub-reports for one weekday-timeslot intersection or you need multiple reports.

Each non-blank sub-report at a row and column of your report tells you: instructor Michel teaches courseCin classroomCRto sectionSfor departmentD.

So the report tells you the same thing overall as a table holding the rows where: instructor Michel teaches courseCin classroomCRto sectionSfor departmentDin timeslotTSon weekdayWD. Notice how we take each column and row of a multi-dimensional report like this and add a column for it to the table for each multi-dimensional sub-report where they intersect.

Probably you want a table telling you the same thing as all reports for all instructors: instructorIteaches courseCin classroomCRto sectionSfor departmentDin timeslotTSon weekdayWD. Notice how we take a parameter in the title and add a column for it to the table.

(Now we don't need to worry about whether Michel identifies one instructor.)

A first design for this report

Instructor names are probably non-unique or non-permanent. So add ids to names and report titles. You probably have more data about instructors, courses and departments. So have tables for them. Apparently a section number is only unique within a course.

-- instructor ID is named NAME and ...
Instructor(id, name, ...)
    CK(id)
-- course NAME ...
Course(name, ...)
    CK (name)
-- department NAME ...
Department(name, ...)
    CK (name)
-- course C_NAME has section S_NUMBER
Course_Has_Section(C_name, S_number)
    CK (C_name, S_number)
    FK(C_name) to Course
-- instructor I_id teaches course C_NAME in classroom CR_NAME to section S_NUMBER 
--     for department D_NAME in timeslot TS_NAME on weekday WD_NAME
Weekly_Lecture(I_id, C_name, CR_name, S_number, D_name, TS_name, WD_name)
    FK(I_id) to Instructor
    FK(C_name, S_number) to Course_Has_Section
    FK(D_name) to Department

Your design details will differ. Maybe courses and/or departments have unique codes. Then you might use them as FKs. Then add a table. Apparently a section can be active, whatever that means.

CKs and Normalizing

A given instructor, timeslot & weekday can only have one weekly lecture. But no smaller subset of those does. So we have Weekly_Lecture CK(I_id, TS_name, WD_name). A given course, section, timeslot & weekday can only have one weekly lecture. But no smaller subset of those does. So we have Weekly_Lecture CK(C_name, S_number, TS_name, WD_name). A given classroom, timeslot & weekday can only have one weekly lecture. But no smaller subset of those does. So we have Weekly_Lecture CK(CR_name, TS_name, WD_name).

Maybe a given course can only be taught for one department? Maybe a given section number can only be taught by a given instructor? By identifying all FDs (functional dependencies) we determine all CKs (candidate keys). Then normalization uses these to possibly suggest "better" choices for base tables.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!