Yesterday, I stored introductory information regarding PTE questions and diverse scoring criteria into MongoDB as the initial dataset.
I set up two tables: MNQuestionInfo
containing 20 sets of PTE question details, and MNQuestionScore
holding diverse scoring metrics. These tables share a OneToMany
relationship, allowing multiple MNQuestionScores to be associated with each record in MNQuestionInfo.
I utilized @DBRef
to establish a connection between these two tables, enabling convenient updates and ensuring data synchronization.
I discovered that the _id
field in MongoDB
documentation can be customized by users, rather than solely generated randomly by the system. To prevent data misalignment or loss of information over time, I opted to designate _id
using my specific naming convention: "id-{document name}-{record name}-{date}"
, for instance, “id-mn-pte-score-fib-202306”. The “202306” in this naming structure denotes the PTE official documentation version for the scoring criteria. Considering possible updates by officials to the scoring criteria, I included the date field to clarify the version for students’ reference.
As of yesterday, I have finished testing and importing data for these two tables. This success has bolstered my confidence to proceed with importing the previously arranged set of 20 PTE questions.
昨天,我将PTE题目的简介和各项评分指标存储到MongoDB作为程序的初始数据。
我创建了两个表,一个名为MNQuestionInfo,包含了20个PTE题型的信息,另一个名为MNQuestionScore,包含了各项评分指标的信息。这两个表之间是一对多的关系,也就是说,MNQuestionInfo表中的每个记录可以有多个关联的MNQuestionScore。
我使用了@DBRef来建立这两张表之间的连接,这样我可以方便地更新它们并保持数据的同步。
此外,我还发现MongoDB的文档ID可以由用户自定义,而不仅限于系统生成的随机码。为了防止长时间运行后出现数据错位或信息丢失的问题,我决定自己命名ID。我的命名方式是”id-{文档名称}-{记录名称}-{日期}”,例如”id-mn-pte-score-fib-202306″。这里的”202306″代表了评分标准是根据PTE官方202306的指南制定的。官方可能会更新他们的评分标准,所以我添加日期部分,以便考生明白这个评分项对应的是哪个版本的标准。
截止到昨天,我已经完成了这两张表的测试和数据导入。这为我提供了信心,可以开始导入之前整理的20个PTE题库。