title: MySQL Database table
body: <p>I really need some help. I have this project and confused how to build its database</p>
  
  <p>I have this general messaging.</p>
  
  <p>students have year and section</p>
  
  <p>I need to send a message in different types</p>
  
  <ol>
  <li>Send to all students</li>
  <li>Send to all students who wants to receive daily update</li>
  <li>Send to students who are belong in specified years</li>
  <li>Send to students who are belong in that year who wants to receive daily update</li>
  <li>Send to students who's belong to sections </li>
  <li>Send to students who's  belong to sections and who wants to receive daily update</li>
  <li>Send to students who's year is and section is</li>
  <li>Send to specific students</li>
  </ol>
  
  <p>some features </p>
  
  <pre><code>Resend notification to new students
  Time of notification to end sending
  </code></pre>
  
  <p>now here is my structure of database</p>
  
  <pre><code>message_queue
  
  id
  type
  message
  isWantToReceive
  date_added
  </code></pre>
  
  <p><code>type</code> field value is json string</p>
  
  <p>i save it something like this</p>
  
  <p>sample value</p>
  
  <pre><code>id    type                                                                                      Message        isWantToReceive   date_added
  1     a:1:{s:3:"all";a:0:{}}                                                                     Hi welcome!    0                 2009-12-2
  2     a:1:{s:6:"others";a:5:{s:7:"year";a:1:{i:0;s:11:"1";}s:10:"section";a:1:{i:0;s:7:"1";}}}   Hi welcome!    0                 2009-12-2
  </code></pre>
  
  <p>then i have a cron job sender that will query it and send message depending on the <code>type</code>.</p>
  
  <p>My problem is when querying all the notification that been send like </p>
  
  <p>get all notification that been send to <code>year 2</code> or <code>year 1 section 1</code></p>
  
  <p>since my <code>type</code> field is a json. Can you help me restructure my database design on how my features work.</p>