One of the features I wanted on the site from the start was to have a basic blogging function. On the blog I could write about my experiences with creating the site or the test projects that are the reason for the site or just write about my thoughts relating to the technologies I'm using (or want to be using).
To start with in creating the blog, I wasn't going to be too fussed with how the blog content got added to the database - I could implement some admin functionality later to make that easier for me, I just wanted to get a simple table structure together where I could show blog entries that I'd added to the database manually and go from there.
That meant the first step therefore was to define a data model to host the blog entries I would input and the result of my design is below:  The main items needed in the blog database are: - Blog - In case I want to have multiple blogs on the site, it will differentiate which blog they belong to
- Blog Entry - To hold a single Blog Entry
- Comments - To hold comments against a blog entry. I also added a parent comment id for the comments table because I had a Google Wave/Slashdot like idea to do hierarchical comments, where by you could comment under a comment.
- Blog Label - To hold labels or tags against a blog
- BlogAuthors - To keep track of who is authoring blog posts
- lnkBlogLabels - a join table to take the many to many relationship between blog entries and labels.
Now that I have the database in place, I can create some LINQ to SQL Entities to access the blog entries and relay those to the relevant view to show them. As I'm thinking that eventually I'll have a look at Entity Framework or other ORM systems later, I've also decided to go for the Repository pattern to hide away the implementation of the Data Entity Layer from the controllers.

Now I have a repository of blogs in which I can query from the blog controller to pass on to the relevant blog view. The scenarios that the blog controller will have to handle (eventually) are an index listing - say last 10 posts, a paged archive of 10 posts at a time, filtered lists by date (year/month) or label and finally to view an individual blog entry. Also will need to add a post method to receive the input from when a user adds a comment.
Now that I've implemented the Blog Controller I will need to create the relevant views to match the actions returned via the controller. I'll do this by adding typed views (right click on the views folder and select Add->View...) and using the MVC provided wizard to create some default views.
Lastly we will need to play with the controller routing to handle the requests for the blog controller and then that's it we have a simple blog, with some very basic features that I will extend over time. Also at some point later I'll need to add a neat system for getting blogs into the database, for the moment I'll just stick to adding it the SQL directly.
Now to try and add the first of the extended features, a RSS feed based off the content... I'll blog about that experience in the near future. |