BigDC Posted October 9, 2009 Share Posted October 9, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/177057-opinions-on-blog-storage/ Share on other sites More sharing options...
xsist10 Posted October 9, 2009 Share Posted October 9, 2009 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; Quote Link to comment https://forums.phpfreaks.com/topic/177057-opinions-on-blog-storage/#findComment-933561 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.