title: One-to-one and one-to-many data formats in ArangoDB
body: <p>New to graph modeling and ArangoDB, I am trying to replace a relational database. For one-to-one or one-to-many relations, I'm struggling to find a correct way to structure my documents and edges.</p>
  
  <p><img src="https://i.stack.imgur.com/cr0lC.png" alt="UML representation of database"></p>
  
  <p>For example, to replace tables <code>auth_credentials</code>, <code>auth_fb</code>, <code>auth_google</code> which contains information allowing users to log in with different services (username-password, facebook, google). I can imagine 3 ways of structuring the data:</p>
  
  <ul>
  <li>Create collections <code>auth_*</code> with the authentication information, and edgeCollections <code>auths_users</code> to link them to users. This matches well the schema above, but I find it cumbersome to create 1 document and 1 edge for each authentication object.</li>
  <li>In my <code>users</code> documents, have a attribute <code>auths</code> which contains arrays of objects with authentication information. I expect it would be difficult to query users based on some authentication information, and this is probably missing the point of graphs.</li>
  <li>Create edgeCollections <code>auth_*</code>, with <code>_from</code> and <code>_to</code> linking to the handle of the user that own the authentication information.</li>
  </ul>
  
  <p>I like the last option better, but I'm fearing it is an antipattern to have edgeCollections where we always have <code>_from == _to</code>. Similarly for <code>groups</code>, I would make them edges from and to their administrator.</p>
  
  <p>To summarize: to represent data B that belongs to data A, is it a good approach to create an edge (from A to A) containing the data of B?</p>