Database – Make sure that the room number of a course section with a certain restriction is within the permitted rooms for this course

In the following situation, I have difficulty making restrictions. This is a hypothetical scenario for practicing the DB design.

Imagine a rule in a school that says Courses some are taken firmly Rooms, e.g: Mathematics course can only be taken in rooms 101, 102 and 110 Course can have many Sections, So I have to make sure none Section of Mathematics course is only taken in the specified Rooms,

Now I'm doing one Course-Room Take relationship through the PK of both Course and Room, The Section The relation is created by the PK of Course and adding the Section Number with it.

For storing the Rooms of Sections, a relation Section-Room created. The Section-Room The table should only contain rows that match that Course-Room Relationship. How can I limit this from that relationship Course-Room Relationship?


A sample ERD is created here: https://dbdiagram.io/d/5e4433459e76504e0ef15e24

The schema as DBML is subsequently inserted as a backup.

// Store info about a Course
Table course {
  course_pk int (pk) 
  course_code varchar(13) (not null, unique)
  course_name varchar(200) (not null)
}

Table room {
  room_pk int (pk)
  room_no int
}

Table section {
  section_pk int (pk)
  course_id int
  section int
}
Ref: section.course_id > course.course_pk

Table course_room {
  course_room_pk int (pk)
  course_id int
  room_id int
}
Ref: course_room.course_id > course.course_pk
Ref: course_room.room_id > room.room_pk

Is it ever a good idea to list a Python section so that you get the index twice?

Sorry for the strange title, but I couldn't think of a better way to explain it. I saw this from someone once and didn't think it was a good idea, but I wanted to check it out. Basically, he wanted to return the numbers 0-3 and do two different things with it. Suppose he wanted to use one as a key for a dictionary and the other for a value calculation:

d{0:0, 1:1, 2:4, 3:9}

So he did this to return the index twice:

d = {}
for i, v in enumerate(range(4)):
    d(i) = v**2

Is it better than writing? d(i) = i**2? I found it strange to list range(4), I know this could be a bit subjective, but is this bad design or just a preference? What is the best course of action?

dg.differential geometry – Local embedding near the null section

To let $ E rightarrow N $ be a vector bundle, $ M $ a varied and let $ varphi: E rightarrow M $ be a smooth card. Let us assume that we have along the zero section
$$
begin {cases}
varphi | _ {N} text {is an embedding} \
(d varphi) _ {x} text {is injective} for all x in N
end {cases}.
$$

Does this follow? $ varphi $ is an embedding in a neighborhood of $ N $?

Using an argument based on local diffeomorphism on a neighborhood of an embedding it can be shown that $ varphi $ is injecting on a neighborhood of $ N $, But is it also a local embedding?