title: Building a RESTful API based on a relational database
body: <p>I am trying to build a RESTful API.  I understand how RESTful API's work and I have developed a nice database structure and model for my api along with the code for detecting the request type and looping through each "node" individually.</p>
  
  <blockquote>
    <h1>API Model</h1>
  
  <pre><code>Collection      Resource               Table
  
  
  associations    associations/AID       Associations
  
  Users           Users/UID              Users
  
  groups          groups/GID             Groups
  
  events          events/EID             Events 
  
  UID/events      UID/events/EID         Events_Map
  
  UID/groups      UID/groups/GID         Group_Map 
  
  GID/events      GID/events/EID         Group_Events
  
  AID/events      GID/events/EID         Association_Events
  </code></pre>
    
    <hr>
    
    <h2>Relationships</h2>
    
    <ul>
    <li><p>association -> groups</p></li>
    <li><p>association -> users</p></li>
    <li><p>association -> events</p></li>
    <li><p>user -> groups</p></li>
    <li><p>user -> events</p></li>
    <li><p>group -> users</p></li>
    <li><p>group -> events</p></li>
    </ul>
  </blockquote>
  
  <p>I am having trouble writing the php code for translating database resources into api resources.  I have read a lot of online tutorials for writing REST API's, but none of them address how to deal with nested data.  I would love to use a framework for this project, but it is for school.  </p>
  
  <hr>
  
  <p>In Summary how to I write code to handle complex api requests and generate the necessary database queries even if they include advanced functions such as join.</p>