我想为学习网站创建关系数据库结构。在这个项目中,有课程。课程有主题,主题有作业。每个主题的测验都有类似的日期和时间,每个作业和测验都有提交时间。我应该如何在mongodb中为这种api结构组织数据库,其中将上述课程分配给学生,然后将学生分批分配。
我无法为数据库设计适当的架构。 课程模式:
const courseSchema = new mongoose.Schema({
_id:{type:Number,requre:true},
courseName:{
type:String,
},
// studentid: {
// type: mongoose.Schema.Types.Number,
// ref: 'addstudents'
// },
topics: [
{
type: mongoose.Schema.Types.Number,
ref: 'addtopics' }
],
batch:[
{
type: mongoose.Schema.Types.Number,
ref: 'batch'
}
]
},{ versionKey: false });
主题架构:
const topicsSchema = new mongoose.Schema({
_id:{type:Number,require:true},
topicName:{
type:String,require:true
},
courseId:{
type: mongoose.Schema.Types.Number,
ref: 'course'
},
courseid:{
type:Number,requre:true
},
timing: [{
type: mongoose.Schema.Types.Number,
ref: 'topictime'
}],
assignments: [
{
type: mongoose.Schema.Types.Number,
ref: 'addassignments' }
],
quiz: [
{
type: mongoose.Schema.Types.Number,
ref: 'addquizes' }
]
},{ versionKey: false });
测验模式:
const quizesSchema = new mongoose.Schema({
_id:{type:Number,requre:true},
// topicId:{
// type:Number,requre:true
// },
courseId:{
type:Number,requre:true
},
// classId:{
// type:Number,requre:true
// },
quizname:{
type:String,requre:true
},
topicid: {
type: mongoose.Schema.Types.Number,
ref: 'addtopics'
}
},{ versionKey: false });
分配方案:
const assignmentsSchema = new mongoose.Schema({
_id:{type:Number,requre:true},
topicId:{
type:Number,requre:true
},
courseId:{
type:Number,requre:true
},
// classId:{
// type:Number,requre:true
// },
assignmentname:{
type:String,requre:true
},
topicid: {
type: mongoose.Schema.Types.Number,
ref: 'addtopics'
}
},{ versionKey: false });