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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|