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
https://forums.phpfreaks.com/topic/177057-opinions-on-blog-storage/
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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.