Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
It's not "which is better" that you need to look at, but "Which better fits our needs"? As someone already pointed out for example, storing "Removed by USERNAME" has implications as at some point you may want to have localised versions of that message. You may want to link to that username in the message, and if you later change how users are linked to, you'll need to update all those.

Both your approaches have the two tables needing to be kept in sync, which means you need to do careful transaction work to make sure they don't end up disagreeing. I wouldn't use either, I'd probably have the posts table not know anything about deletions, and the removed table list post_id, deleted_by_id, date etc. SQL will quite happily create the list of all posts with/without deletions for you, you can even build the "Removed by username" message in it.

select posts_tbl.post_id, case deleted_by_id is not null then 'Removed by ' || deluser.name else posts_tbl.message end as message, user.name from posts_tbl left join removed_tbl on posts_tbl.post_id = removed_tbl.post_id left join authors as deluser on removed_tbl.deleted_by_id = deluser.au +thor_id left join authors user on user.author_id = posts_tbl.author_id
.. as a rough example of how that works.

C.


In reply to Re: [OT] When coders don't see eye to eye by castaway
in thread [OT] When coders don't see eye to eye by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (8)
    As of 2014-08-28 09:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (259 votes), past polls