title: MVC design convention: CRUDing inherited models
body: <p>Here's my database structure:</p>
  
  <p><img src="https://i.imgur.com/hrSO9.png" alt="database schema"></p>
  
  <p>In my app I have a company management of customers, employees and branches.</p>
  
  <p>Customers and Employees are associated with one Person, one Individual and one User.
  Branches are associated with one Person and one Company.</p>
  
  <p>So, to insert a new costumer or employee, I have to first insert its common data into <code>Person</code> table, its person data into <code>Person</code> table, then its user data into <code>User</code> table and finally create a new record into <code>Customer</code> or <code>Employee</code> table.</p>
  
  <p>To insert a new branch, I've to first insert its common data into <code>Person</code> table, then its company data into <code>Company</code> table and finally create a new record into <code>Branch</code> table.</p>
  
  <p>I'm new to MVC concept and I'm a bit lost in how I should design my model classes to CRUD them. I'm using CodeIgniter framework, but I think it's irrelevant here. Should I create a separate class model for each database table? If so, how I should code that? (theory only)</p>
  
  <p>For example, to insert a new costumer...</p>
  
  <ol>
  <li>Start a new transaction</li>
  <li>Instantiate a new Person</li>
  <li>Fill Person's data</li>
  <li>Save Person</li>
  <li>Instantiate a new Individual</li>
  <li>Fill Individual's data and relate to its Person</li>
  <li>Save Individual</li>
  <li>Instantiate a new User</li>
  <li>Fill Users' data and relate to its Person</li>
  <li>Save User</li>
  <li>Instantiate a new Costumer</li>
  <li>Fill Costumer's data and relate to its Person</li>
  <li>Save Costumer</li>
  <li>End transaction</li>
  </ol>
  
  <p>Is that correct? Where this code should be, in the costumer's controller? Any better convention to use that database structure (I need to use the third normal form design)? </p>