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
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
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
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
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
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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.
|
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...
|
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,...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |