At the database level, in which table is the relationship between an activity (forum, task, etc.) and the section of a course to which it was assigned stored?
Assignments are not typically assigned at the section level, they are assigned at the course level. You can use differentiated assignments, also called assignment overrides, to get them to specific sections.
If you want the course that the assignment is given to, then you can use the assignment_fact table and look at the assignment_id and course_id fields. The assignment_fact.assignment_id field is keyed to id field of the assignment_dim table and the assignment_fact.course_id is keyed to the id field of the course_dim table. The assignment_dim and course_dim both have a canvas_id column, which will give you the assignment or course ID used in the web interface or the API. Note that the assignment_dim table also has a course_id, which is a duplicate of the assignment_fact.course_id field.
If you are looking for differentiated assignments, then things are a little more challenging, but not terribly so. Here are are assignment_override tables and assignment_override_user tables. Each has a _fact and a _table version.
If you're looking for section overrides, then look at the assignment_override_fact and assignment_override_dim tables. The assignment_override_fact table has assignment_id, course_id, and course_section_id, which are keys to the assignment_dim.id, course_dim.id, and course_section_dim.id columns respectively.
The course_section_dim table contains information about each section, including which course it belongs to. There is no course_section_fact table, however.
The differentiated assignments that go to individual users and not entire sections is handled in a similar fashion, but it uses the assignment_override_user tables.
If you are using differentiated assignments, then you may need to use a combination of the two methods depending on how things are setup. I suspect that the "everyone" or "everyone else" portion of a differentiated assignment is contained in the assignment tables while the specific sections are contained in the assignment_override tables. I have not verified this, though.
Retrieving data ...