Efficiently representing school data

Hi,

Please consider the following folder structure:
There is a School Folder.
Inside that there are 6 subfolders Grade7, Grade8, ... Grade 12.
Inside EACH of these grade folders, there are files like Exam.txt, Quiz.txt, Sports.txt, Debate.txt, etc.
Content of these text files differs but format is the same.
Each line has the student name followed by space separated scores.

For example
Quiz.txt in Grade8 folder has
Alex 6.6 7.8 9.3
Bob 10.0 9.8 8.8
Cathy 5.5 6.6 7.7

Sports.txt in Grade8 folder has
Alex 9.6 10.0 10.0
Bob 10.0 9.8 8.8
Cathy 7.5 6.9 2.1

Quiz.txt in Grade12 folder has
Joe 5.2 6.6 4.3
Sidney 1.0 2.8 5.1
Trisha 0.0 0.0 0.0

I do not have much experience with C++ and was just wondering what is the best way to represent this data, so that it can be read efficiently for further processing.

Please suggest if a map would be the best way to represent this data?
Something like
map<string, map<string, map<string, double*>>> schoolData


To represent Sidney's quiz data
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
map<string, map<string, map<string, double*>>> schoolData;
map<string, map<string, double*> studentquizData;
map<string, double*> studentData;
double* scores;

scores[0] = 1.0;
scores[1] = 2.8; 
scores[2] = 5.1;

studentData["Sidney"] = scores;

studentquizData["Quiz.txt"] = studentData;

schoolData["Grade12"] = studentquizData;

I am using folders like quiz, exam, etc. for simplicity. In implementation, these will be named Ex1, Ex2 that will help in looping the code.

Thank you
One quick qs: the student names in the quiz file are different than in the other 2 files. Should they be the same?
They should be different. Because the first quiz file is from Grade8 while other is from Grade12.
Please suggest if a map would be the best way to represent this data?
Something like

Probably not. I'd suggest some classes or structures to hold the data.

Something more like the following, perhaps?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
struct Student
{
    string name;
    vector<double> grades;
};

struct Class
{
    string name;
    vector<Student> students;
};

struct Grade
{
    int grade_number;
    vector<Class> classes;
};

...

    // In main()
    vector<Grade> grades;
...

This way each "Grade" can have a different number of sub folders and each sub folder can have a different number of students which can each have a different number of test grades.


Thank you very much.
Topic archived. No new replies allowed.