Results 1 to 6 of 6

Thread: Show post for x days?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Show post for x days?

    Hi everyone

    since I last was on this board I have done loads - set up my db and tables, put in an admin and login page etc. Wow lol!

    Well I have a question about posts. Each user can submit a post although I only want it to show for x number of days. Each post therefore has a 'dateadd' and 'datekill' field however I don't really know the best way to implement these... I want to use it so I can show viewers how many days it has left before being removed, and also when the date=datekill I want to remove it from the db.

    How would I accomplish this best?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Show post for x days?

    It is generally considered that if you are storing 'public' data (which you are, as it is on a website with users entering the data) that you shouldn't actually delete data, but merely 'hide' it instead - that way you can settle disputes based on the deleted posts if needed.

    As you have dates in the table, it would be easy to enough to modify queries to add "AND date < datekill" to the Where clauses, so that only valid posts are shown.

    In terms of showing the number of days left, you could calculate it in the query (and return it as part of the recordset), or you could do it in the client app using something like DateDiff in VB.

    I would personally do it in the client myself, as the way in which you display it may vary, for example you might start with "x days", and then decide later to have "x days + y hours".

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Re: Show post for x days?

    Hmmmm, I would have to delete posts eventually because I don't want old posts clogging up my db - if standard time of posting is a month, how long should I keep them after?

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Show post for x days?

    How huge do you think this application will become? We have systems where I work that literally have millions of records. Think of this forum for example. How many threads/posts do you think there are?

    I'm not noticing any degredation of performance because of it. I agree with si_the_geek on this. I wouldn't delete anything. At the most, I would set a status on it and mark it as historical after X days.

    And I also wouldn't put a datekill on it. Just run a simple computation based on the created date and today's date like si mentioned.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Show post for x days?

    How much storage space do you have, and how much will each post use up?

    Based on my memory of your database design, I'm guessing that you won't be running in to trouble anytime soon, a each post is very small in data terms (much less than posts here for example).

    I would recommend keeping them for a least a year, and longer (potentially forever) if you have the space.


    edit: I think I disagree with you on datekill TheHobo - I think it could be useful, as people could decide how long their post lasts (if that functionality is wanted). Then again, in data-size terms it would probably be better to have a Byte to store the number of days.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Re: Show post for x days?

    Well ok guys I think I will keep them in the db for as long as memory permits.... I guess I just want to be economical with space etc..

    What I was thinking was just to do a query when showing the posts table and then only show those where datekill > todays date (or something like that lol..)

    Anyway thx for the advice, Ill take it onboard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width