Display hierarchical data in C #

I am trying to develop a page to display student / class results for a subject / teacher.

Some classes have groups in which students participate, and some have only students. The subject is considered by one or more teachers. This may change in the future, and I want the design to be as flexible as possible (i.e., objects can be divided into modules or to individual test results, classes can be further grouped by year, etc.)

I want to display the final results in a grid that I can expand and collapse to average the results (class on Y and object on X).

Can I have 3 database tables as follows:

**class_structure**
id (int) PK
description (varchar)
parent_id (int) FK to id

The highest level will be the class (without a parent identifier), and the lowest level will be the student.

**subject_structure**
id (int) PK
description (varchar)
parent_id (int) FK to id

, , .

**results**
id (int) PK 
class_structure_id (int) FK
subject_structure_id (int) FK
date (datetime)
reult (int)

? , ?

asp.net ​​ ( sproc LINQ ?)

.

( html #?) (.. , ( , , )).

<table border="1" padding="2">
 <tr>
  <td></td>
  <td></td>
  <td colspan="2" align="center">Subj 1</td>
  <td colspan="2" align="center">Subj 2</td>
 </tr>

 <tr>
  <td></td>
  <td></td>
  <td>Teacher 1</td>
  <td>Teacher 2</td>
  <td>Teacher 1</td>
  <td>Teacher 2</td>
 </tr>
 <tr>
  <td rowspan="2">Class 1</td>
  <td>Student 1</td>
  <td>90</td>
  <td>55</td>
  <td>75</td>
  <td>100</td>
 </tr>
 <tr>
  <td>Student 2</td>
  <td>40</td>
  <td>95</td>
  <td>65</td>
  <td>39</td>
 </tr>
</table>

, , ( , , ) ( class_structure_id /sproc ) .

, ?

+3
4

1:) <table>, <ul> <ol>. .

2:) # - - , Id. :

class TreeElement 
{
 public TreeElement Parent {get;}
 public IEnumerable<TreeElement> Children{get;};
 public AddChild(TreeElement element }
 public bool IsRoot { return Parent == null; }
 public bool IsLeaf { return Children.Length == 0; }
 public bool IsBranch {return !IsRoot && !IsLeaf; }
}

, . , , ;) , .

3:) SQL. if/else SQLTeam , .

4:) linq .

+2

JQuery , JQuery-, .

http://www.jstree.com/

JsTree ( jQuery - MIT GNU General Public License (GPL) Version 2). - jstree.

+1

:

Person
 - Person_ID (PK)
 - Type (student/teacher etc)
 - Name etc...

PersonGroups
 - PersonGroup_ID (PK)
 - Description etc..

Subjects
 - Subject_ID (PK)
 - Description etc...

Classes
 - Class_ID (PK)
 - Subject_ID (FK)
 - Description etc...

PersonClassMembership
 - Person_ID (FK)
 - PersonGroup_ID (FK)
 - Class_ID (FK)

PersonGroupMembership
 - PersonGroup_ID (FK)
 - Person_ID (FK)

, , , /.

"", , , .

0

I do not agree with your table design. Putting mixed data on the same table with recursion is a really bad idea. Do not do this if you do not need to store tree data in the database. For your question, the best design:

  • Students table
  • Table teachers
  • Classes tables
  • table SubjectTypes (type_id, description) English, math, sports, etc.
  • table Subjects (class_id, teacher_id, subject_type_id)
  • StudentDistribution table (stu_id, subject_id)
  • Grade table (stu_id, subject_id, grade)
0
source

Source: https://habr.com/ru/post/1764849/


All Articles