title: DynamoDB M-M Adjacency List Design Pattern
body: <p>Referring to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-adjacency-graphs.html" rel="nofollow noreferrer">amazon</a>. I was wondering if anyone could help me.</p>
  <p>The first image is of the table, and the second is the GSI. Here is the table:
  <a href="https://i.stack.imgur.com/pA1n6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pA1n6.jpg" alt="here" /></a></p>
  <p>On the table, I don't understand how one is to create the sort-key? Is this one attribute that stores both Bill-ID and Invoice-ID? or two separate attributes? I have a feeling it's the one flexible attribute, and if so how do you differentiate one from the other? And how are we meant to construct the query on the sort-key?</p>
  <p>Is it just by looking the prefix &quot;Bill-&quot; or &quot;Invoice-&quot;?
  The practice of DynamoDB seems to make use of dashes (&quot;-&quot;) to separate values in an attribute. If anyone can give me use cases of such things, I would be grateful as well, but I am going off tangent unless it's important in this case.</p>
  <p>Now, this is very relatable and very interesting <a href="https://youtu.be/xV-As-sYKyg?t=1897" rel="nofollow noreferrer">YouTube</a>, where the presenter uses ONE product table to store various types of items: Books, Song Albums, and Movies; and each has their own attributes.</p>
  <p>Again I have a problem understanding the sort-key used there. I understand that productID=1 is bookID, and productID=2 is an Album. Now where it gets confusing now is what I circled in red. These are the tracks of Album 2. However, the structure of the sort key is &quot;albumID:trackID&quot;. Now, where is the &quot;trackID&quot;? Is it meant to substitute the word &quot;trackID&quot; with actual ID? or is this meant to be a text exactly as &quot;albumID:trackID&quot;?.</p>
  <p>What if I wanted to query a specific trackID? what would be the syntax of my query?</p>
  <p>Please see the image here from the youtube:
  <a href="https://i.stack.imgur.com/kXJmB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kXJmB.jpg" alt="enter image description here" /></a></p>
  <p>Thank you all in advance!!! :-)</p>