-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchema.js
More file actions
176 lines (145 loc) Β· 5.29 KB
/
Schema.js
File metadata and controls
176 lines (145 loc) Β· 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Agar tum **MongoDB schema design** kar rahe ho **School Management System** ke liye, to tumhe **best relational structure** banana hoga jo **performance aur scalability** ke liye sahi ho.
// ---
// ## π **MongoDB Schema Design for School Management System**
// **Collections ka overview:**
// - **Users** (Students, Teachers, Parents, Admin)
// - **Classes** (Subjects, Schedules, Teachers)
// - **Attendance** (Daily student attendance)
// - **Exams** (Marks & grading system)
// - **Transport** (Bus details, Routes, GPS tracking)
// - **Payments** (Fees & transactions)
// - **Chat** (Real-time messaging)
// ---
// ## π **1. Users Collection (Students, Teachers, Parents, Admin)**
// β
**User Roles:** `Student`, `Teacher`, `Parent`, `Admin`
// β
**Relationships:** Student ke Parent aur Class se link honge
// β
**Authentication:** Multi-role access ke liye `role` field
// ```js
// {
// _id: ObjectId("65a1b0c3d9a8c2b4"),
// name: "Rahul Sharma",
// email: "rahul@example.com",
// password: "hashed_password",
// role: "Student", // Teacher, Parent, Admin
// class_id: ObjectId("65a1b2c3d9a8c2b5"), // Student ki class
// parent_id: ObjectId("65a1b3c3d9a8c2b6"), // Parent reference
// contact: "+91-9876543210",
// createdAt: ISODate("2024-02-13T10:00:00Z")
// }
// ```
// ---
// ## π **2. Classes Collection (Subjects, Teachers, Students)**
// β
**Students aur Teachers ko map karega**
// β
**Subjects aur schedule bhi store honge**
// ```js
// {
// _id: ObjectId("65a1b2c3d9a8c2b5"),
// class_name: "10th Grade",
// section: "A",
// teacher_id: ObjectId("65a1b4c3d9a8c2b7"), // Class Teacher
// subjects: ["Math", "Science", "English"],
// student_ids: [ObjectId("65a1b0c3d9a8c2b4"), ObjectId("65a1b8c3d9a8c2b9")],
// createdAt: ISODate("2024-02-13T10:00:00Z")
// }
// ```
// ---
// ## π **3. Attendance Collection (Daily Attendance)**
// β
**RFID/Biometric based Attendance**
// β
**Date-wise student attendance track karega**
// ```js
// {
// _id: ObjectId("65a1c0c3d9a8c2b8"),
// student_id: ObjectId("65a1b0c3d9a8c2b4"),
// date: ISODate("2024-02-12"),
// status: "Present", // Absent, Late, Leave
// class_id: ObjectId("65a1b2c3d9a8c2b5"),
// createdAt: ISODate("2024-02-13T10:00:00Z")
// }
// ```
// ---
// ## π **4. Exams & Results Collection**
// β
**Marks aur Grades ko track karega**
// β
**Subject-wise performance analysis**
// ```js
// {
// _id: ObjectId("65a1d0c3d9a8c2c0"),
// student_id: ObjectId("65a1b0c3d9a8c2b4"),
// subject: "Math",
// marks: 85,
// grade: "A",
// exam_date: ISODate("2024-02-10"),
// teacher_id: ObjectId("65a1b4c3d9a8c2b7"),
// createdAt: ISODate("2024-02-13T10:00:00Z")
// }
// ```
// ---
// ## π **5. Transport Collection (Bus Tracking)**
// β
**Live GPS tracking ke liye**
// β
**Student aur Bus ka mapping**
// ```js
// {
// _id: ObjectId("65a1e0c3d9a8c2c1"),
// bus_number: "DL 10 AB 1234",
// driver_name: "Suresh Kumar",
// driver_contact: "+91-9876543211",
// route: "Sector 12 to School",
// student_ids: [ObjectId("65a1b0c3d9a8c2b4"), ObjectId("65a1b8c3d9a8c2b9")],
// gps_location: { lat: 28.7041, lng: 77.1025 },
// createdAt: ISODate("2024-02-13T10:00:00Z")
// }
// ```
// ---
// ## π **6. Payments & Fees Collection**
// β
**Online fee payment (Razorpay Integration)**
// β
**Invoice aur due tracking**
// ```js
// {
// _id: ObjectId("65a1f0c3d9a8c2c2"),
// student_id: ObjectId("65a1b0c3d9a8c2b4"),
// amount: 5000,
// status: "Paid", // Pending, Failed
// payment_method: "Razorpay",
// transaction_id: "txn_ABC123",
// createdAt: ISODate("2024-02-13T10:00:00Z")
// }
// ```
// ---
// ## π **7. Chat Collection (Real-time Messaging)**
// β
**Teacher-Student-Parent communication**
// β
**Multi-role chat system**
// ```js
// {
// _id: ObjectId("65a200c3d9a8c2c3"),
// sender_id: ObjectId("65a1b0c3d9a8c2b4"), // Student
// receiver_id: ObjectId("65a1b4c3d9a8c2b7"), // Teacher
// message: "Sir, homework kab submit karna hai?",
// timestamp: ISODate("2024-02-13T10:05:00Z"),
// seen: false
// }
// ```
// ---
// ## π **Relations Between Collections**
// | **Collection** | **Reference** |
// |---------------|-------------|
// | `users` | `class_id`, `parent_id` |
// | `classes` | `teacher_id`, `student_ids` |
// | `attendance` | `student_id`, `class_id` |
// | `exams` | `student_id`, `teacher_id` |
// | `transport` | `student_ids`, `bus_number` |
// | `payments` | `student_id`, `transaction_id` |
// | `chat` | `sender_id`, `receiver_id` |
// school collection
// "_id": ObjectId,
// "name": "ABC Public School",
// "address": "Indore, MP",
// "contact": "9876543210",
// "adminId": ObjectId, // Principal ka userId
// "createdAt": ISODate,
// "updatedAt": ISODate
// ---
// ## π₯ **Conclusion**
// 1οΈβ£ **Data Normalization**: **Users, Classes, Transport, Attendance alag rakho** taaki query fast ho.
// 2οΈβ£ **Indexes Use Karo**: `student_id`, `class_id`, `teacher_id` indexes honi chahiye.
// 3οΈβ£ **Aggregation Pipelines**: Reports aur filtering ke liye **$lookup, $match** ka use karo.
// 4οΈβ£ **Performance Optimization**: Large data sets ke liye **Sharding aur Indexing** ka use karo.
// Agar tumhe **schema me koi aur modification ya optimization chahiye**, to batao! π