title: Utilizing Realm Object Server for a collaborative application
body: <p>So for the past few days I have been reading through the Realm documentation and I am very excited to use this data synchronization solution in upcoming projects.  After using standard database schemas (SQL, Firebase, etc).  I am still not fully understanding the best way to utilize Realms.  I see Realms are meant to be very flexible, but there are not many examples or docs of how to set up and efficient structure.  </p>
  
  <p>So, I wanted to just provide a simple collaborative app idea, and show my first thoughts on how I would set up the Realms. For simplicity, lets say this is a messaging app that contains chatrooms.  Users can create chat rooms and the owner of the room can invite people to their room.  Once that user is added to a room, they will have read/write access to the room.</p>
  
  <p>My current structure:</p>
  
  <p>1) A realm for each user.  (/Users/uid) .  Each one of these realms will have public read access and write access only for the user that owns it.</p>
  
  <p>2) A realm for each chatroom.  (ChatRooms/uid) .  Each chat room will hold the various models pertaining to that specific room (messages, likes, notifications, etc).  Initially only the owner will have read/write access, everyone else will have no access.  The owner can then start handing out read/write permissions to the users they invite.</p>
  
  <p>3) A public realm that holds mappings of a user to a chatroom. (ChatMembers).  This realm will hold models that have two attributes, a user id and a chatroom id.  A user can query this realm by there id to see what chatroom realms they will have access to.  </p>
  
  <p>I feel this is a very basic structure, but I am still not positive if this is utilizing Realm to the best of its abilities.  Also, if anyone can lead me to some better documentation, please do.  Would appreciate anyones feedback!!</p>