First of all I am making it clear that, I am not using any OR Mapper framework to solve this problem, coz I need to understand the model from the ground up.
OK. Let's see the table designs:
Course - table
------------------
ID | CourseName
------------------
1 | C++
2 | Java
------------------
Teacher - table
-----------------------
ID | TeacherName
-----------------------
1 | Professor X
2 | Professor Y
-----------------------
CourseTeacher - table
---------------------------------------------
ID | CourseID | TeacherID | ClassTime
---------------------------------------------
1 | 1 | 1 | Monday 10:55
2 | 1 | 2 | Thursday 10:55
3 | 2 | 1 | Tuesday 11:45
4 | 2 | 2 | Wednesday 11:45
---------------------------------------------
How should I design my classes in C# and using List<T>
?
N.B. Please note the ID
in the CourseTeacher
- table. I think the main challenge of the class design is to maintain unique IDs in CourseTeacher - table.
N.B. Please note that there is also a requirement to manipulate data from within a TransactionContext.
There can be another problem like is:
User - table
------------------
ID | UserName
------------------
1 | a
2 | b
------------------
Role - table
-----------------------
ID | RoleName
-----------------------
1 | c
2 | d
-----------------------
UserRole - table
---------------------------------------------
ID | UserID | RoleID | Remarks
---------------------------------------------
1 | 1 | 1 | xy
2 | 1 | 2 | yz
3 | 2 | 1 | zx
4 | 2 | 2 | xx
---------------------------------------------