Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

NOMGUY's avatar
Level 16

Blog Website

I am creating a blog website of my own using Laravel 5.6. I want to gain some tips like what all databases i should create and what options should i have on my blog website. Thanks in advance

0 likes
11 replies
Sergiu17's avatar

Tell us features of your blog, and we will tell you the database tables you need :)

Let me give you an example

  1. One of the feature is to add/delete/update posts - for this you need posts table

  2. Another features is to support tags - for this, Many To Many tags with posts

  3. Images - one table called images

And at the end you will find answers in your question :)

NOMGUY's avatar
Level 16

What about, Likes and Comments. Can you please explain how can I create these two things. I mean the tables and the relationships.

Sergiu17's avatar
// likes
$table->increments('id');
$table->unsignedInteger('post_id');
$table->unsignedInteger('user_id');

It has post_id and user_id

// comments
$table->increments('id');
$table->unsignedInteger('post_id');
$table->unsignedInteger('user_id');
$table->text('comment');

post_id - comment related to it, user_id - user which posted comment and comment - comment itself.

NOMGUY's avatar
Level 16

Ahaan... Nice. What about the Views. I mean to say the no. of times page is visited. How to do that? @sergiu17

Sergiu17's avatar
// create_posts_table.php migration
$table->integer('views');


// controller
public function show($id)
{
    $post = Post::findOrFail($id);

    $post->increment('views');

    return view('posts.show', compact('post');
}

You could do this in many different ways.

Redis is another option

1 like
NOMGUY's avatar
Level 16

Haha... i know @Cruory .. But I am creating my own website, so I thought it could be a good way to have some tips. It's never too late to learn things.. ;)

Please or to participate in this conversation.