title: Database Design: Use mapping tables or include data directly in tables
body: <p>I am writing a project management web app just for practice. The basic idea is that a user can add a project to the app and then manage their tasks and appointments related to the project through the interface. I'm currently designing the Database and I was wondering what best practice would dictate here.</p>
  
  <p>I have 4 tables so far:</p>
  
  <pre><code>+----------+   +-------------+   +--------------+   +-------------+
  |Users     |   |Projects     |   |Tasks         |   |Appointments |
  +----------+   +-------------+   +--------------+   +-------------+
  |id        |   |id           |   |id            |   |id           |
  |username  |   |project_name |   |task_name     |   |appt_name    |
  |fname     |   |project_desc |   |task_details  |   |appt_details |
  |sname     |   |             |   |task_deadline |   |appt_date    |
  +----------+   +-------------+   +--------------+   +-------------+
  </code></pre>
  
  <p>I'm taking the basic relationships as:</p>
  
  <ul>
  <li>one <code>user</code> can have many <code>projects</code>,<code>tasks</code>, and <code>appointments</code>.</li>
  <li>one <code>project</code> can have many <code>users</code>, <code>tasks</code> and <code>appointments</code>.</li>
  <li>one <code>task</code> can have many <code>users</code>, but only be associated with one <code>project</code>. A <code>task</code> can't be associated with an <code>appointment</code>.</li>
  <li>The rules for the <code>tasks</code> also apply to the <code>appointments</code>.</li>
  </ul>
  
  <p>My question is: when is it suitable to use mapping tables and when is it suitable to include the data directly in the associated table? My take on my example would be:</p>
  
  <ul>
  <li>have a mapping table for each of users-projects/tasks/appts because there can be many users for each type and many of each type per user</li>
  <li>in the tasks and appointments tables include a <code>project_id</code> field that can be used to associate tasks and appointments with projects and thereby the users of that project.</li>
  </ul>
  
  <p>Would this be the correct approach or is there a better solution? I'm fairly new to database design so I would really appreciate some constructive criticism</p>