title: How to store one to many relationship data in dynamodb
body: <p>As per my data model, I need to store many to many relationship data items in dynamodb
  Example : 
  I have a field called studentId and every studentId will have several subjects assigned to him.</p>
  
  <p>Requirement : </p>
  
  <ol>
  <li><p>So that for a given studentId, I need to store all the subjects. I would need to get all the subjects assigned to a given student.</p></li>
  <li><p>Similary, for a given subjectId, I need to know the studentIds whom that subject has been assigned to.</p></li>
  </ol>
  
  <p>am planning to store this in dynamoDb as follows : </p>
  
  <ul>
  <li>Table1 : StudentToSubjects : 
  
  <ul>
  <li>Hash Key : StudenId, </li>
  <li>RangeKey: subjectId</li>
  </ul></li>
  </ul>
  
  <p>so that if I query using only primaryKey, it would give me all the rows having that primary key and all the different hash keys.</p>
  
  <p>Secondary Key as </p>
  
  <ul>
  <li>secondary HashKey: <code>subjectId</code> </li>
  <li>Secondary RangeKey: <code>studentId</code></li>
  </ul>
  
  <p>I wanted to know if this makes sense or the right thing to do. Or there are better ways to solve this problem.</p>