-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDATABASE_DIAGRAM.dbml
More file actions
229 lines (211 loc) · 7.19 KB
/
DATABASE_DIAGRAM.dbml
File metadata and controls
229 lines (211 loc) · 7.19 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// LearnPulse Database Schema in DBML Format
// Use at https://dbdiagram.io/
Table users {
_id ObjectId [primary key]
firstName varchar [not null]
lastName varchar [not null]
email varchar [not null, unique]
password varchar [not null]
accountType varchar [note: 'admin | instructor | student']
active boolean [default: true]
approved boolean [default: true]
additionalDetails ObjectId [ref: > profiles._id]
courses ObjectId[] [ref: > courses._id, note: 'Array of course IDs']
image varchar
token varchar [note: 'Optional authentication token']
resetPasswordTokenExpires timestamp
courseProgress ObjectId[] [ref: > course_progress._id, note: 'Array of progress IDs']
wishlist ObjectId [ref: > wishlists._id]
cart ObjectId [ref: > carts._id, unique]
totalRevenue number [note: 'Revenue for instructors']
createdAt timestamp
updatedAt timestamp
}
Table profiles {
_id ObjectId [primary key]
gender varchar [note: 'User gender']
dateOfBirth varchar [note: 'Date of birth']
about varchar [note: 'About user']
contactNumber number
}
Table courses {
_id ObjectId [primary key]
courseName varchar [not null]
courseDescription text
instructor ObjectId [ref: > users._id, not null]
whatYouWillLearn varchar
courseContent ObjectId[] [ref: > sections._id, note: 'Array of section IDs']
ratingAndReviews ObjectId[] [ref: > rating_reviews._id, note: 'Array of review IDs']
price number
thumbnail varchar
category ObjectId [ref: > categories._id]
tag varchar[] [not null, note: 'Course tags']
studentsEnrolled ObjectId[] [ref: > users._id, not null, note: 'Array of student IDs']
instructions varchar[]
status varchar [note: 'Draft | Published | Pending | Rejected', default: 'Draft']
averageRating number [note: 'Average rating 0-5', default: 0]
totalRatings number [default: 0]
isApproved boolean [default: false]
rejectionReason varchar
totalRevenue number
createdAt timestamp
updatedAt timestamp
}
Table categories {
_id ObjectId [primary key]
name varchar [not null]
description varchar
courses ObjectId[] [ref: > courses._id, note: 'Array of course IDs']
}
Table sections {
_id ObjectId [primary key]
sectionName varchar [not null]
subSection ObjectId[] [ref: > sub_sections._id, not null, note: 'Array of subsection IDs']
}
Table sub_sections {
_id ObjectId [primary key]
title varchar
timeDuration varchar [note: 'Duration of video']
description varchar
videoUrl varchar
}
Table carts {
_id ObjectId [primary key]
userId ObjectId [ref: > users._id, not null, unique]
courses ObjectId[] [ref: > courses._id, note: 'Array of course IDs']
totalAmount number [default: 0]
createdAt timestamp
updatedAt timestamp
}
Table wishlists {
_id ObjectId [primary key]
userId ObjectId [ref: > users._id, not null, unique]
courses ObjectId[] [ref: > courses._id, note: 'Array of course IDs']
createdAt timestamp
updatedAt timestamp
}
Table payments {
_id ObjectId [primary key]
userId ObjectId [ref: > users._id, not null]
courses ObjectId[] [ref: > courses._id, not null, note: 'Array of course IDs']
amount number [not null]
currency varchar [default: 'USD']
paymentMethod varchar [default: 'stripe']
stripeSessionId varchar
stripePaymentIntentId varchar
status varchar [note: 'pending | completed | failed | refunded', default: 'pending']
couponCode varchar
discountAmount number [default: 0]
finalAmount number [not null]
paymentDate timestamp
createdAt timestamp
updatedAt timestamp
}
Table certificates {
_id ObjectId [primary key]
userId ObjectId [ref: > users._id, not null]
courseId ObjectId [ref: > courses._id, not null]
certificateId varchar [not null, unique, note: 'Unique certificate identifier']
studentName varchar [not null]
courseName varchar [not null]
instructorName varchar [not null]
completionDate timestamp
issueDate timestamp
certificateUrl varchar [note: 'URL to certificate PDF/image']
isValid boolean
createdAt timestamp
}
Table rating_reviews {
_id ObjectId [primary key]
user ObjectId [ref: > users._id, not null]
rating number [not null, note: '1-5 rating']
review text [not null]
course ObjectId [ref: > courses._id, not null]
isApproved boolean [default: true]
isRemoved boolean [default: false]
createdAt timestamp
updatedAt timestamp
}
Table quizzes {
_id ObjectId [primary key]
courseId ObjectId [ref: > courses._id, not null]
sectionId ObjectId [ref: > sections._id]
subSectionId ObjectId [ref: > sub_sections._id]
title varchar [not null]
description varchar
questions json [note: 'Array of question objects with options and answers']
totalPoints number [not null, default: 0]
passingScore number [not null, default: 60]
duration number [note: 'Duration in minutes', default: 30]
attemptLimit number [default: 3]
isActive boolean [default: true]
createdAt timestamp
updatedAt timestamp
}
Table quiz_results {
_id ObjectId [primary key]
userId ObjectId [ref: > users._id, not null]
quizId ObjectId [ref: > quizzes._id, not null]
courseId ObjectId [ref: > courses._id, not null]
answers json [note: 'Array of answers with correctness']
score number [not null]
percentage number [not null]
passed boolean [not null]
attemptNumber number [not null]
timeTaken number [note: 'Time taken in seconds']
submittedAt timestamp [not null]
createdAt timestamp
}
Table course_progress {
_id ObjectId [primary key]
courseID ObjectId [ref: > courses._id]
userId ObjectId [ref: > users._id]
completedVideos ObjectId[] [ref: > sub_sections._id, note: 'Array of completed subsection IDs']
}
Table discussions {
_id ObjectId [primary key]
courseId ObjectId [ref: > courses._id, not null]
sectionId ObjectId [ref: > sections._id]
subSectionId ObjectId [ref: > sub_sections._id]
userId ObjectId [ref: > users._id, not null]
content text [not null]
parentId ObjectId [ref: > discussions._id, note: 'For nested replies']
isInstructorReply boolean
isPinned boolean
likes ObjectId[] [note: 'Array of user IDs who liked']
createdAt timestamp
updatedAt timestamp
}
Table coupons {
_id ObjectId [primary key]
code varchar [not null, unique]
discountPercent number [note: '0-100']
discountAmount number [note: 'Fixed discount amount']
discountType varchar [note: 'percent | fixed', default: 'percent']
expiryDate timestamp
maxUsage number [note: 'Null means unlimited']
usedCount number
courseId ObjectId [ref: > courses._id, note: 'Optional: specific to a course']
isActive boolean
minPurchaseAmount number [note: 'Minimum purchase to use coupon']
createdAt timestamp
updatedAt timestamp
}
Table otps {
_id ObjectId [primary key]
email varchar [not null]
otp varchar [not null]
createdAt timestamp [note: 'Expires after 5 minutes']
}
// Key Relationships Summary:
// - Users have many Courses (instructor relationship)
// - Users have many Courses (enrolled students)
// - Users have one Cart and one Wishlist
// - Courses belong to one Category
// - Courses have many Sections
// - Sections have many SubSections
// - Users have many Ratings/Reviews
// - Users have many Course Progress records
// - Users have many Quiz Results
// - Courses have many Payments (transactions)
// - Courses have many Certificates (completions)