473,387 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

What Logic is Used Behind "add to favorite" feature on a member based website?

ilya Kraft
134 100+
Hello,

Right, so I decided to add "Add to favorites feature" to my member based website. But I kind of don't know where to start. I mean what logic is behind it?

I was thinking of customizing a check box so members can easily add or remove from favorites. So When Check box is clicked that article would go into favorites list of that member. But what structure of database should I use and how to relate Favorited articles to a member who Favorited them?

Thnx
Aug 14 '11 #1

✓ answered by Oralloy

A two field relation should work. Just user and favorite. Primary key is user+favorite; if necessary, add a secondary (non-unique) index on user.

If you want to keep track of things in a controlled maner, you can add timestamp, db-username, and comment fields.

How you architecht your solution depends on your requirements. Is there a limit to the number of favorites? How about time between adding favorites? Will favorites fall away after some period of time, say one year? How about number of times visited?

Good Luck!
Oralloy

4 2416
Oralloy
988 Expert 512MB
A two field relation should work. Just user and favorite. Primary key is user+favorite; if necessary, add a secondary (non-unique) index on user.

If you want to keep track of things in a controlled maner, you can add timestamp, db-username, and comment fields.

How you architecht your solution depends on your requirements. Is there a limit to the number of favorites? How about time between adding favorites? Will favorites fall away after some period of time, say one year? How about number of times visited?

Good Luck!
Oralloy
Aug 15 '11 #2
ilya Kraft
134 100+
Allright, so say when user clicks "Favorite" button, than the id of favorited article and say username of the person who clicked it will go into table with fields favorite and username.

And than I can select id's of Favorited articles that are related to username of the member right? What do you mean by primary key user+favorite? Should I set them both to primary key when setting up fields?

You also mentioned some really good requirement's like falling favorites away after 1 year. Could you explain how it's done? say for period like 6 months?

Thank You
Aug 15 '11 #3
Oralloy
988 Expert 512MB
ilya,

Having the primary key of User+Favorite guarantees record uniqueness. A user shouldn't add a favorite twice. If they are able to, then maybe you should use an abstract record key. I really don't know what your database design criteria are, and I'm assuming you want "quick" results. GOOD DESIGN will use an abstract key.

As for having things fall away, that's a management call, I don't like it when people disappear data on me, but sometimes it's appropriate. For instance when the favorited value is no removed, or no longer exists. It's a function of what you are recording and how you want to manage your users. Alternately, you can add notation fields like "unavailable" to the record.

How a purge isdone is simple. Every so often, a process is run that deletes records that meet some criterion. For example, closed accounts might have their favorites purged. Typically the command looks like DELETE FROM favorites WHERE (timestamp < now()-60);. The exact syntax is a function of your database.

As to the how of periodically running a task, that's a function of the system you're building in and how the site will be managed. It can be a completely automated function (e.g. cron job, schedued task, etc.), or you can administratively have a person run the necessary commands once a month.

Talk with your team and/or management and find out requirements are appropriate to your web site. I know that you were probably given the task of adding favorites. That's easy. Now, think about how they will be used.

Luck!
Oralloy
Aug 15 '11 #4
make table with these fields ::
1->id (auto_increment, primary key)
2->Title
3->Description
4->Imagepath
5->PostBy

make other table with these fileds :
table name => article_fav_details
1-> id (auto inrement, primary key)
2->article_id
3->member_id

with this table you can find total members who made fav. perticular article by article id as well as perticular member's total favourite articles.
May 17 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Julian | last post by:
Hi I am just trying to get to grips with ado.net . I simply wish to add data from some text boxes back to a new row in the dataset on clicking a save button. How do you create the new row in...
0
by: Yi | last post by:
Hi, I am a scientist and new to .NET programming. On my PC, I am using Windows 2000 professional with IIS, SQL Server 2000 (standard, personal), Visual Basic .net (2003, standard). By following...
0
by: blesh | last post by:
So I've created my own custom Form, and I'd like to add it to the list that comes up when you say "Project > Add New". I'm sure I have to make some sort of template or something crazy... maybe...
10
by: msnews.microsoft.com | last post by:
Hi, How do I add a reference in VC++.NET? In VB.NET and VC#.NET, there's an option in "Project" menu called "Add Reference". This will add a .NET DLL reference to the current project. After I...
3
by: Samuel R. Neff | last post by:
I just started having a problem with the Add Reference dialog not displaying in VS.NET 2003. Whenever I click Add Reference the dialog doesn't display. I've tried several different projects and...
1
by: PJSimon | last post by:
In regards to this MSDN article: http://support.microsoft.com/default.aspx?scid=kb;en-us;306149 .... how do I add the registry key? I got confused on three points: 1) I do not have a key...
3
by: Maxwell2006 | last post by:
Hi, I am using Visual Studio 2005. I have added a DLL into GAC. I can confirm that by going to C:\WINDOWS\assembly and see the assembly name.
2
by: Parasyke | last post by:
Please help.... I have a form that I successfully add records to that I want to copy and turn into a form for editing records from that same table (It is imperitive that it be done this way, rather...
3
rsmccli
by: rsmccli | last post by:
Using AC2002 Hello. I am working with an existing DB that has "Add New" command buttons on two forms. When I, an Admin, click the buttons, they work properly, and a new, blank form is created,...
1
by: corey farrar | last post by:
I'm having trouble understanding why i'm getting the error 'add is not a member of system.array' I'm using an arraylist and when I hover over my declaration of memberarray As ArrayList() the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.