title: Mongodb database Schema Design with shared data
body: <p>Hi  I am newbie to mongodb.I am using java. </p>
  
  <p>I have 4 tables Tenant,system,authorization in my relational table. </p>
  
  <p>Something like this.</p>
  
  <pre><code>Table            Fields
  
  Tenant           Tenant_ID(PK), Tenant_INFO
  System           System_ID(PK), System_Info
  Authorization    System_ID, Autho_Info.
  System_prop      System_ID, Prop_Info, Tenant_ID
  </code></pre>
  
  <p>In System_prop table, Tenant_ID refers the Tenant Table Tenant_ID (PK), System_ID refers the System Table System_ID. </p>
  
  <p>In Authorization table, System_ID refers System tabel System_ID</p>
  
  <p>I am switching my database from relational to mongodb. First thing I need to do is Schema design. </p>
  
  <p>Query I need to do is:</p>
  
  <ol>
  <li><p>SELECT A.Prop_Info, A.System_ID From System_prop A, SYSTEM B, TENANT C Where A.System_ID = B.System_ID AND A.Tenant_ID = C.Tenant_ID</p></li>
  <li><p>SELECT A.System_ID, A.Prop_Info FROM Authoization A, SYSTEM B WHERE A.System_ID = B.System_ID</p></li>
  </ol>
  
  <p>Can anyone help me how to design these tables as collections in mongodb? </p>
  
  <p>Do i need to embed r use dbref? Help me to design the schema for this. </p>