One to one and many to many representation of entites in mongodb -


so use sqlserver through entity framework , got email saying azure raised prices on azure sql elastic db's, again!. way going mongodb , need translating fluent api mongo document?

public coursemappings()                 {                     hasmany<user>(s => s.student)                         .withmany(c => c.course);                 }   public addressmappings()             {                  hasrequired(c => c.student)                 .withrequireddependent(u => u.address);             }   public studentmapping()             {                  hasrequired(c => c.address)                 .withrequiredprincipal(u => u.student);              } 

got 3 tables, student, address , courses, how model in mongodb?i know address embedded in student 1:1 relationship have figured out. question can done in 1 document(an example) or courses separate document studentid many many relationship students?

the data model in mongodb dependent on "query access pattern" of application. understand you, application access data student id or student data. recommend have 1 collection. collection schema data model below:-

{     "_id" : objectid("57971c2b4895ddf87c8747ea"),     "studentid" : 1,     "studentname" : "name",     "address" : {         "name" : "street name",         "addressline1" : "line 1",         "addressline2" : "line 2",         "post code" : "gruhfyn"     },     "courses" : [          {             "courseid" : 1,             "coursename" : "science"         },          {             "courseid" : 2,             "coursename" : "english"         },          {             "courseid" : 3,             "coursename" : "maths"         }     ] } 

student model data types


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -