Mongodb database Schema Design with shared data

前端 未结 3 1615
别跟我提以往
别跟我提以往 2021-01-15 05:06

Hi I am newbie to mongodb.I am using java.

I have 4 tables Tenant,system,authorization in my relational table.

Something like this.

Table          


        
3条回答
  •  佛祖请我去吃肉
    2021-01-15 05:33

    You may need just one collection with all the documents, of course you will end up by having too many repeated field but this is the trick to scale well. For the Relations the type one to many and one to one you will just remove the identifier and put the rest of the attributes because MongoDB will take care of the primary key. ('I love MongoDB for that').

    For the many to many relationship that you have between Tenant and System you will have to change it to an array in MongoDB data structure.

    coll{
    Tenant : 'value',
    tenant_info : 'value',
    Sys_info: 'value' ,
    auth_info: 'value' ,
    Prop_info : array [ 'value','value',''value....]
    }
    

提交回复
热议问题