Click here to Skip to main content
15,843,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,

Detailed description goes below.

The Requirement

I'm developing a Blogging page which includes designing both front and back end. Using MVC WebAPI as service and MySQL to store data.
My blog page requires to be presented in 2 different layouts as of now, and in future I may add more layouts for the same page. The challenge here is designing the database table since contents for different layouts will be presented in different formats, e.g.-3 paragraphs and 2 images in first layout, 5 paragraphs and 3-4 images in second layout.

What I'm planning

To create a MySQL table with various columns for both paragraphs and images(P1,P2,P3,IMG1,IMG2...etc), but again to me this approach looks not so future proof considering modifying the table would be hard in future.

Not finding a proper approach I come here to get a right approach to to my requirement. The attached screenshot is an initial view of my first blog description page.


What I have tried:

After going through various concepts "Storing the entire HTML content in database" sounded the most feasible solution since it's quite straightforward approach to do. However this approach isn't feasible for me since:

1. It means hard coding the data-->Resulting hard to modify in future.
2. I've plans to develop mobile apps in future in which case this HTML data would be meaningless for me.
Updated 27-Feb-17 6:44am

1 solution

There is nothing stopping you storing HTML in the database as the blog itself.
The important point is to not include any display specific code.

For display purposes consider using CSS to manipulate the HTML (and any images).

Have a look at Zen Garden to get a better idea of what I mean - CSS Zen Garden: The Beauty of CSS Design[^]

Android has its own way of applying styles Styles and Themes | Android Developers[^]

So perhaps store your blog as plain text or xml, convert to the appropriate format (HTML/android:text) and apply the appropriate style as required, when required.
Share this answer
P_Dash 28-Feb-17 2:37am    
I'm using HTML5/Bootstrap/AngularJS in my application. Storing HTML without Bootstrap/CSS in server and then collaborating is too complex/painful and at most of the times not possible at all.

Unfortunately this approach couldn't be considered. FYI. I already have tried storing and manipulating how you mentioned.
CHill60 28-Feb-17 7:54am    
Storing the content i.e. the data separately from the formatting or UI element is exactly the purpose of modern tools (such as the ones you mention) and is absolutely the way forward. In other words you must separate the concerns of data and presentation or you are doomed to rewriting lots and lots of code.

I also question your use of the word "Table" - your database design should contain many tables and you absolutely should not have columns for your images in your main table - use a link table so the number of images is unlimited.

This blog may prove helpful: Design Pattern: Blog ERD[^]
P_Dash 1-Mar-17 0:22am    
What you said is correct. I've various tables for different kind of data storage/formats. Just for the sake of simplicity I mentioned as table.
Will have a look into the link, hopefully it'll answer my question upto an extent.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900