1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Reviews - Using DB or Files?

Discussion in 'Content Management' started by Darkhodge, Jun 12, 2006.

  1. #1
    Hey,


    Im just building a site and want people to be able to review products etc... I was just wondering whether I should make use of a DB for reviews or if I could do it with a file (e.g. CSV text file w/ 1 line per review) which Id include into the page.

    The main area of concern here is performance. Im wondering if a file based reviews system would be faster than a DB system once the site grows. Just to clarify things this is what I mean:

    Sorry that this may seem like a stupid question! Im new to PHP... :eek:


    Thanks
     
    Darkhodge, Jun 12, 2006 IP
  2. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use a database.

    mySQL uses files to store all database information. You can simply copy those files to copy a database from one server to another. The server security isn't stored in the data files.

    What you may want to do eventually is generate static pages from the database but that will be awhile. A mySQL database can handle tens of thousands of records on a moderatly powered server (less than 1 Ghz) without much trouble.

    Put data into the database first, then worry about generating simple flatfiles to speed up rendering.
     
    KalvinB, Jun 12, 2006 IP
  3. topsearch

    topsearch Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    DB is the way to go. Particularly when your site starts to grow. Mysql does all the indexing for you so you'll have faster access than with a flat file unless you want to write some sort of flat file index utility. Come to think of it, there are probably such utilities available.

    However, for me at least, mysql is easier.
     
    topsearch, Jun 13, 2006 IP
  4. TikTok

    TikTok Peon

    Messages:
    1,761
    Likes Received:
    273
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I would definitely go with databases. Moving databases is much easier than moving files.

    File backups and global changes could cost you extra time.
     
    TikTok, Jun 14, 2006 IP
  5. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #5
    Ah right - thanks for all your input guys! It really is helpful.
     
    Darkhodge, Jun 19, 2006 IP
  6. ClearVisionDesigns.co.uk

    ClearVisionDesigns.co.uk Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    DB all the way. Much easier to implement and performance will probably be better. Also much easier to export/backup etc.
     
  7. Silent

    Silent Banned

    Messages:
    71
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    you will face search indexing problems with flat files.
    so, go with the db..
     
    Silent, Jun 22, 2006 IP
  8. Mystique

    Mystique Well-Known Member

    Messages:
    2,579
    Likes Received:
    94
    Best Answers:
    2
    Trophy Points:
    195
    #8
    And you can also face problems with mysql because the continuous connectivity problems due to misconfiguration, unavailability or limitations imposed by the hosting service.

    I prefer a sincere flat text db or xml based because if site is down the db is down, otherwise, if site is up and mysql down, the errors are continuous including inaccessibility to your whole site for the time you notice it and fix it.

    Mysql is faster indeed, but connectivity errors occur more often. In last instance, go with ASP and use an MS-access database.
     
    Mystique, Jun 22, 2006 IP
  9. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #9
    That's a really bad host if they're having connectivity problems with the database.

    Since my personal server is a 900Mhz PIII and DMOZ contains over 7 million records for link information it's impossible to run DMOZ straight from the database. At least, not the database generated by dmoz2mysql.

    But, the db generated by dmoz2mysql does a fine job of parsing out all the DMOZ information correctly and does build the database correctly. So what I'm doing first is pulling out all the data from the database and with some creative MD5ing am generating a flatfile database with hundreds of files holding all the records. The first run leaves me with three sets of files: content, structure and link definitions.

    The next run is to combine those three sets into one set. I then use the MD5 of the directory the user is in the figure out while file the record is in, read in the file, find the record, unserialize it and process it for display.

    Muuuuuch faster. Although it's taking hours to build that flatfile db. The other thing I can do is then take the second run and inject it back into mySQL using hundreds or thousands of tables. I'll see which is faster: Windows finding the file to open or mySQL finding the table to search.

    So what it basically boils down to is flatfile may be a better option in some circumstances. But, always store your information in a database first.

    I'll get my DMOZ mirror running hopefully this weekend and I'll report then which is faster: flatfile or mySQL

    The other reason for using flatfile is when your host doesn't allow long running cron jobs. In which case, it may be impossible to import all the data into your hosts database. You may have to build a flatfile on a local system first and then upload the files to your host.

    Both have their place. I just tend to prefer DB whenever possible.
     
    KalvinB, Jun 24, 2006 IP
  10. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #10
    So all in all people seem to be in favor of the DB system right? Cool :)

    Thanks again for all your inputs. :D
     
    Darkhodge, Jun 26, 2006 IP
  11. randomlande

    randomlande Peon

    Messages:
    118
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Personally I dont like databases, since I don't know my way around them too well. I like text files.
     
    randomlande, Jun 27, 2006 IP