So I'm trying to make a system that is one of many styles DB in mongo using java.I am trying to recreate a school grading database where there are: teachers, classes, periods, students and their grades attributes. But my question is how do I implement one to many in java, for example, teachers and the classes they teach.
因此,我正在尝试使用java创建一个mongo中众多样式数据库之一的系统。我正在尝试重新创建一个学校评分数据库,其中包括:教师,班级,期间,学生及其成绩属性。但我的问题是如何在java中实现一对多,例如,教师和他们教授的课程。
DB的大图
更精确的DB图
2 个解决方案
#1
0
Instead of this you code have a student as a new doc, the name is an index and grades/assignments are an array with hashmaps within. And have collections made when a teacher tries to access it for the first time.
而不是这个代码将学生作为新文档,名称是索引,成绩/分配是一个带有哈希图的数组。并且当教师第一次尝试访问时收集。
EXP: If Mr.Rogers has 3 classes, ask him for the classes and create them, such as "Rogers_math_alg_2" etc
EXP:如果Mr.Rogers有3个班级,请他上课并创建它们,例如“Rogers_math_alg_2”等
#2
1
I think that the question that you're asking is more about the schema design itself, the fact that it's "in java" seems irrelevant to your question.
我认为你问的问题更多的是关于模式设计本身,它是“在java中”似乎与你的问题无关。
Anyhow, it's quite a broad question and a broad topic. There's rarely, if ever, one way to approach a schema design.
无论如何,这是一个相当广泛的问题和广泛的话题。如果有的话,很少有一种方法可以实现模式设计。
I'd suggest you start with broadening your knowledge of the schema design process, and the various tradeoffs of different approaches.
我建议您首先扩展您对架构设计过程的了解,以及不同方法的各种权衡。
Here are some resources to get you started:
以下是一些可以帮助您入门的资源:
- 6 Rules of Thumb for MongoDB Schema Design: Part 1 (links to parts 2 and 3 within)
- MongoDB架构设计的6个经验法则:第1部分(链接到第2部分和第3部分)
- Data Model Design (MongoDB docs)
- 数据模型设计(MongoDB文档)
I think that after you've gone through those you should have some ideas around various approaches to your particular model, and you can check back here for additional help if needed. :-)
我认为在你完成这些之后你应该对你的特定模型的各种方法有一些想法,如果需要你可以在这里查看以获得更多帮助。 :-)
#1
0
Instead of this you code have a student as a new doc, the name is an index and grades/assignments are an array with hashmaps within. And have collections made when a teacher tries to access it for the first time.
而不是这个代码将学生作为新文档,名称是索引,成绩/分配是一个带有哈希图的数组。并且当教师第一次尝试访问时收集。
EXP: If Mr.Rogers has 3 classes, ask him for the classes and create them, such as "Rogers_math_alg_2" etc
EXP:如果Mr.Rogers有3个班级,请他上课并创建它们,例如“Rogers_math_alg_2”等
#2
1
I think that the question that you're asking is more about the schema design itself, the fact that it's "in java" seems irrelevant to your question.
我认为你问的问题更多的是关于模式设计本身,它是“在java中”似乎与你的问题无关。
Anyhow, it's quite a broad question and a broad topic. There's rarely, if ever, one way to approach a schema design.
无论如何,这是一个相当广泛的问题和广泛的话题。如果有的话,很少有一种方法可以实现模式设计。
I'd suggest you start with broadening your knowledge of the schema design process, and the various tradeoffs of different approaches.
我建议您首先扩展您对架构设计过程的了解,以及不同方法的各种权衡。
Here are some resources to get you started:
以下是一些可以帮助您入门的资源:
- 6 Rules of Thumb for MongoDB Schema Design: Part 1 (links to parts 2 and 3 within)
- MongoDB架构设计的6个经验法则:第1部分(链接到第2部分和第3部分)
- Data Model Design (MongoDB docs)
- 数据模型设计(MongoDB文档)
I think that after you've gone through those you should have some ideas around various approaches to your particular model, and you can check back here for additional help if needed. :-)
我认为在你完成这些之后你应该对你的特定模型的各种方法有一些想法,如果需要你可以在这里查看以获得更多帮助。 :-)