views:

31

answers:

3

So I was asked by my management to incorporate a way for users to mark pages in my website as "favorite" and have them show up in a special list. This site has a static structure (I do not generate pages). I am wondering about the best way to do that. My first thought was to store it in the database (since user information is also stored there), but I suppose I could also use the Profile properties of ASP.NET. Is there any other ways I have not considered? How would you all do it?

+2  A: 

More than likely you will get better performance when storing multiple pieces of information to store this in a separate table with something like UserId, PageUrl, PageTitle or something similar so that the information is all available at once.

This also gives you centralized access to common links, should you remove a page from the system, you could then remove it quickly from the "Favorites" system.

Mitchel Sellers
Not to mention allows finding out a top 10 list of pages.
Oded
And then they'll want Grouping, and Sort Order, and ...
Jeff O
Very true on both accounts!
Mitchel Sellers
+3  A: 

I'd use a database, mainly because I want to store a list of things with certain properties (specifically, a list of urls, with details on page title, user that favorited etc). Most likely I'd do something like this in my DB:

FavoritePages
*************
pageId (pk, int)
title (string)
url (string)

Favorites
*********
userId (fk)
pageId (fk)

If you use profile properties, you're maintaing a list of links for each user, basically in a (serialized?) string for each user (for that's how profile properties are stored...). If the title or url of one page changes, there's no way for you to update that and have it reflected on all the users' pages.

Tomas Lycken
This is *exactly*, to the letter, what I was doing to this point. Great to know I was on the right track!
Matthew Jones
A: 

I would go for database. have people vote for pages and remember the votes, so people can change their vote. Calcualte totals and / or average (depending on voting cmechanism) and take it from there.

If you talk of a single user system (not correlating user A votes with user B votes) you CAN use the profile mechainsm as you will store a small list anyway. What you do loose is the mecahnism to query for those efficiently (as administrator).

Pretty largely a design decision based on personal preferences. Arguments ca nbe made in both directions. I would possibly go with the database - in the light of easier maintenance and later expansion.

TomTom