Jump to content

Opinions on blog storage?


BigDC

Recommended Posts

Hello,

I am creating a site that may have hundreds maybe thousands of users (hopefully), each user will have his/her own blog that is stored and retrieved in MySQL. My question is this, should I make it to where it creates a database for each user's blog, or just use ONE database and have it store all the blogs for each user in it?

 

What would you do, your opinions please?

Link to comment
Share on other sites

Would it be worthwhile to create an entire database for a blogger who writes maybe 1 blog entry a month?

 

It will be a lot easier if you create 1 database and add a field to your table that maps to an author.

 

i.e.:

 

CREATE TABLE author (

    id int(11) unsigned not null auto_increment,

    name varchar(60) not null default '',

    PRIMARY KEY (id)

);

 

CREATE TABLE blog_entry (

    id int(11) unsigned not null auto_increment,

    author_id int(11) unsigned not null default 0,

    title varchar(100) not null default '',

    content text,

    created datetime,

 

    PRIMARY KEY (id),

    INDEX author_id (author_id)

);

 

# This will get the last 10 blog entries with their author names

SELECT e.title, e.content, a.name

FROM blog_entry e

JOIN author a ON (e.author_id = a.id)

ORDER BY e.datetime DESC LIMIT 10;

 

# This will get the last 10 blog entries for a particular author (by name)

SELECT e.title, e.content, a.name

FROM blog_entry e

JOIN author a ON (e.author_id = a.id)

WHERE a.name = "[Authors Name]"

ORDER BY e.datetime DESC LIMIT 10;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.