Architecture – Status update & news feed database design / architecture

Architecturedatabase-designsql

Imagine a application similar to Facebook, where you have status updates and a news feed. The names and profile pictures can be changed. There are also several different types of updates requiring a different layout template for each type.

I hate my implementation and would like some feedback on how to improve it. When I store the status update in the database, I basically store the HTML template in the database with some of the update specific information in it as well. Since the profile pic and poster name can change, I'm keeping placeholders in the HTML stored in the database like '{USER_PROFILE_PIC}' and replacing that with the most current value when the record is pulled & displayed. I hate doing it this way because if we want to do a design change down the road, we are stuck with this HTML in the database.

I'm doing this all in SQL Server. I'm open to other databases if needed, I just am looking for a good way to pull dynamic status updates from a database and display them with up to the moment info.

TIA

Best Answer

Ok, if you're using mvc then you're definitely doing this a bit wrong... Consider mvc, its the model => view => controller framework. The whole point of the framework is to ensure a nice and clean separation of concerns.

When you start storing templates in your db, your muddling those concerns. What I would do is convert each of my templates into a partial view. The whole reason partial views exist is to serve as little code templates.

I would store the data only in the database.

So your app basically has this:

the db containing only the data required for a status update. a controller that loads this data, and then passes it to the relevant view a view that displays the data in its own required format.

Related Topic