Click to See Complete Forum and Search --> : Best way to manage a blog.


Daniel T
05-13-2004, 03:09 PM
OK, for the last little while, I've been working on my blog site, adding various things, removing others. The biggest change would be using a MySQL Database to manage my blog. I was wondering what the best approach would be(ie: should I store all the entries in 1 DB, and the comments in the other? should I store each individual entry and the comments for that entry in 1 DB? or should I take an entirely different approach?). The way I'm doing it now involves all the entries in 1 DB and the comments in another, but it is representing a couple problems when I go to put them all together. What I need to know is which is the best and most convenient way to manage this? Thanks,
-Dan

PS: I have unlimited DB's.

**EDIT**
I guess I should also mention that I'm using phpMyAdmin to handle the DB's and using PHP to call and write to them.

Conor
05-13-2004, 03:23 PM
I really cant tell you what you should do but for me I have one database with two tables. One tables holds all the blog entries and one holds all the comments i find it very easy to manage this way.

Daniel T
05-13-2004, 03:28 PM
If you have one table with all the comments, though, how do you get it to just call the ones for the specific entry? (please bear with me, I'm a complete n00b to MySQL)

Conor
05-13-2004, 03:58 PM
when inserting the comment have a field called replyto. In this you insert the ID of the current entry. then to call it you would do

$query2 = "SELECT * FROM comments WHERE replyto='".$ID."'ORDER BY ID ASC";

Daniel T
05-13-2004, 04:33 PM
Cool, thanks. Also, I've already put all my comments into seperate tables, depending on the entry. Now, I want to move all the comments to one table. Is there a way to move them without having to type them all in again? I can't seem to find one :confused:
-Dan

Conor
05-13-2004, 09:14 PM
back it up maybe but I dont know you could just not move comments over?

Daniel T
05-13-2004, 10:12 PM
OK, I don't know enough about MySQL yet, to be taking this on, so I've decided to do a tutorial or two, and manage the DB with PHP, rather than phpMyAdmin, that way I will learn it. Ok, it gets me to insert the following code:
<?
$user="username";
$password="password";
$database="database";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
mysql_query($query);
mysql_close();
?>
Ok, I know what all of that means except for this:
PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id)
Could someone explain what this line does please? Thanx,
-Dan

Sam
05-14-2004, 01:14 AM
I'm also a MySQL newb, so I'm not sure on KEY id_2 (id), but PRIMARY KEY (id) tells MySQL to make id the default key, and UNIQUE id (id) tells it not to let to values in the id column have the same value