开发者

How would you make a "Favorite Pages" system

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开发者_如何学Go all do it?


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜