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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ilya Kraft
    New Member
    • Jan 2011
    • 134

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

    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
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    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

    Comment

    • ilya Kraft
      New Member
      • Jan 2011
      • 134

      #3
      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

      Comment

      • Oralloy
        Recognized Expert Contributor
        • Jun 2010
        • 988

        #4
        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 "unavailabl e" 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 administrativel y 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

        Comment

        • Bharat383
          New Member
          • Aug 2011
          • 93

          #5
          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_det ails
          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.

          Comment

          Working...