(Alex)minjun yu

© Minjun Yu. All rights reserved.

How To Store Blog Post In Database

When designing a blog post, one of the key concerns is how to store the message for easy CRUD.

Solution 1 - Store the message in HTML ONLY

Post will be stored and edited in HTML format only. A fancy WYSIWYG editor need to be plugged into the app.

Solution 2 - Store the message in Markdown ONLY

No WYSIWYG editor is needed but it requires HTML rendering for both creating posts and showing posts to users.

Solution 3 - Store the message in both Markdown and HTML

Create post by writing markdown and store both the markdown and rendered HTML in database. For showing to users, only the HTML is retrieved. This solution works the best because a blog post is created only once and infrequently edited while retrieving the post is more frequent.

For this website, I am using a java library flexmark.