Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You probably want to split out the different activities into different tables. This will give you more flexiblity on how you query the data.</p> <p>If you choose to use UNION, make sure that the you use the same number of columns in each select query that the UNION is comprised of.</p> <p><strong>EDIT:</strong> I was down-voted for my response, so perhaps I can give a better explanation.</p> <p><strong>Split Table into Separate Tables and UNION</strong></p> <p>I recommended this technique, because it will allow you to be more explicit about the resources for which you are querying. Having a single table for inserting is convenient, but you will always have to do separate queries to join with other tables to get meaningful information. Also, you database schema will be obfuscated by a single column being a foreign key for different tables depending on the data stored in that row.</p> <p>You could have tables for comment, update and subscription. These would have their own data which could be queried on individually. If, say, you wanted to look at ALL user activity, you could somewhat easily use a UNION as follows:</p> <pre><code>(SELECT 'comment', title, comment_id AS id, created FROM comment) UNION (SELECT 'update', title, update_id as id, created FROM update) UNION (SELECT 'subscription', title, subscription_id as id, created FROM subscription) ORDER BY created desc </code></pre> <p>This will provide you with a listing view. You could then link to the details of each type or load it on an ajax call.</p> <p>You could accomplish this with the method that you are currently using, but this will actually eliminate the need for the 'reference_table' and will accomplish the same thing in a cleaner way (IMO).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload