OK, as may have noticed i'm building! ;)
Here's my latest hair pulling dillema:
I'm making a public access blog that will allow comments. I need to add a editlog table and am trying to work out if I should re-design a little or, how best to incorporate it. Here's what I have: (only fields needed to explain...)
blogtable:
I thought of just adding an emum field with ('c','p') for comment or post but, would I be better of redesigning the way the system works and putting the comments in the same table as the posts?
Anyone understand what I mean? ;)
Nick
So, you dont think combining the posts and comments is a good idea? - making the title and desc fields NULL so comments don't have them and adding a 'parent' field?
It really wouldn't be any extra work to make two tables and as the more complex qureies would be for the administrator only (like find out which admin has made which edits) it wouldn't really matter if those queries were'nt lightning fast...
Nick
Otherwise, you can let the first column in the 2nd table auto increment, and add the #'s to the main table (column "comments", comma separated and updated when new comments are posted). That way it will be much faster and easier to grab the comments (from the second table) since you know exactly which ones to grab, and since that table will be larger than the other one. Each comment would have its own ID, which means one less column in that table (even though it will be one more in the main one).
[pre]
CREATE TABLE blogentries (
id INT NOT NULL AUTO_INCREMENT,
author INT NOT NULL,
date TIMESTAMP NOT NULL,
title VARCHAR(255) NOT NULL,
description VARCHAR(255) NOT NULL,
text TEXT NOT NULL,
PRIMARY KEY(id)
)CREATE TABLE blogcomments (
id INT NOT NULL AUTO_INCREMENT,
parent INT NOT NULL,
author INT NOT NULL,
date TIMESTAMP NOT NULL,
text TEXT NOT NULL,
PRIMARY KEY(id)
)[/pre]
Nick