title: Modelling NoSQL database (when converting from SQL database)
body: <p>I have a SQL database that I want to convert to a NoSQL one (currently I'm using RavenDB)</p>
  
  <p>Here are my tables:</p>
  
  <p><strong>Trace:</strong> </p>
  
  <pre><code>ID (PK, bigint, not null)
  DeploymentID (FK, int, not null)
  AppCode (int, not null)
  </code></pre>
  
  <p><strong>Deployment:</strong></p>
  
  <pre><code>DeploymentID (PK, int, not null)
  DeploymentVersion (varchar(10), not null)
  DeploymentName (nvarchar(max), not null)
  </code></pre>
  
  <p><strong>Application:</strong></p>
  
  <pre><code>AppID (PK, int, not null)
  AppName (nvarchar(max), not null)
  </code></pre>
  
  <p>Currently I have these rows in my tables:</p>
  
  <p>Trace:</p>
  
  <pre><code>ID: 1 , DeploymentID: 1, AppCode: 1
  ID: 2 , DeploymentID: 1, AppCode: 2 
  ID: 3 , DeploymentID: 1, AppCode: 3 
  ID: 3 , DeploymentID: 2, AppCode: 1
  </code></pre>
  
  <p>Deployment:</p>
  
  <pre><code>DeploymentID: 1 , DeploymentVersion: 1.0, DeploymentName: "Test1"
  DeploymentID: 2 , DeploymentVersion: 1.0, DeploymentName: "Test2"
  </code></pre>
  
  <p>Application:</p>
  
  <pre><code>AppID: 1 , AppName: "Test1"
  AppID: 2 , AppName: "Test2"
  AppID: 3 , AppName: "Test3"
  </code></pre>
  
  <p>My question is: HOW should I build my NoSQL document model ?</p>
  
  <p>Should it look like:</p>
  
  <pre><code>trace/1
  {
   "Deployment": [ { "DeploymentVersion": "1.0", "DeploymentName": "Test1" } ],
   "Application": "Test1"
  }
  
  trace/2
  {
   "Deployment": [ { "DeploymentVersion": "1.0", "DeploymentName": "Test1" } ],
   "Application": "Test2"
  }
  
  trace/3
  {
   "Deployment": [ { "DeploymentVersion": "1.0", "DeploymentName": "Test1" } ],
   "Application": "Test3"
  }
  
  trace/4    
  {
   "Deployment": [ { "DeploymentVersion": "1.0", "DeploymentName": "Test2" } ],
   "Application": "Test1"
  }
  </code></pre>
  
  <p>And what if Deployment 1 gets changed ? Should I go by each document and change the data?</p>
  
  <p>And when should I use references in NoSQL ?</p>