How to create one to many in mongoDB using java

472 views
Skip to first unread message

Bhagyesh Patel

unread,
Apr 4, 2017, 6:49:17 AM4/4/17
to mongodb-dev


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.

big diagram of DB

more precise diagram of DB

Wan Bachtiar

unread,
May 14, 2017, 11:40:49 PM5/14/17
to mongodb-dev

Hi Bhagyesh,

Questions related to the use of MongoDB (i.e. your question) are better sent to mongodb-user group. This group (mongodb-dev) is for discussion for/by/about developers/development/code of MongoDB.

my question is how do I implement one to many in java

I’ll suggest to review One-to-Many relationships: embedded and One-to-Many relationships: references in the manual to get started with your schema. See also Blog: 6 rules of thumb for schema design for more considerations when designing a schema.

To get started using MongoDB with Java please see MongoDB Java driver Quick-Start. You may also find M101: MongoDB for Java Developers a useful free online course for working with the Java driver.

If you have further questions, please post a new discussion on mongodb-user group along with information below:

  • MongoDB version.
  • MongoDB Java driver version.
  • Example of MongoDB documents.

Regards,

Wan.

Reply all
Reply to author
Forward
0 new messages