Databases Vs FlatFile - Some thoughts

Discussion in 'MySQL' started by Embrance, Jan 21, 2007.

  1. #1
    As i see, MySQL stores all data in files as well. So what exactly is the thing that makes is fastet than flatfiles?
    Im in the process of making a flatfile site management tool,and going for flatfile(with caching options & ststic page generation possibility).
    What would the advantages be?
     
    Embrance, Jan 21, 2007 IP
  2. smallbuzz

    smallbuzz Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you use MySql, it'll be easier to manage the data. If you use flat file, you have to define your own file format and write code to parse the file. The time it takes to load the file will increase as your file gets bigger and bigger. Database is more flexible and efficient in the long run.
     
    smallbuzz, Jan 24, 2007 IP
  3. ConnorWilson

    ConnorWilson Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't know if I would describe MySQL as storing data in files, becuase its storing them in a database... I guess thats the obvious note.

    Anyways, flat file never comes out on top IMO, unless your server doesn't support MySQL, or any other type of DB. As noted above, efficiency and flexibility but also its easier to use.
     
    ConnorWilson, Jan 24, 2007 IP
  4. blfast

    blfast Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    MySQL files do not contain just the data - also indexing and metadata. The indexing makes accesses fast. As for metadata - it can store access control lists (who can read from the DB, write to it, etc). Also typing - think about a column that contains entries like "20070123". Are they strings? Numbers? Dates? That's important when you want to, say, compare them or take averages. A full database has all of that information in the "files", the flat file won't.
     
    blfast, Jan 26, 2007 IP
  5. Embrance

    Embrance Well-Known Member

    Messages:
    192
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #5
    Well,my idea of flatfile was this:
    Have the file(whatever.ext)and in there store IDs.
    So,each the structure would be:
    ID(number)|variable type|content
    Im still looking into this,since im not sure if the above example would work at all.
     
    Embrance, Jan 26, 2007 IP
  6. saidev

    saidev Well-Known Member

    Messages:
    328
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    140
    #6
    What method of reading and writing of the flat file are you thinking about? If it's sequential than you'll have read the file from the top to the the position of the data you are looking for. While a database take care all of that for you. As mention earlier in this thread, database take care of all the hard work for you, as such read and writing files and locating in the correct place without using you own search algorithm. I guess it also depends on what application you are writing. Are you writing something for web backend or a desktop application?
     
    saidev, Jan 26, 2007 IP
  7. smallbuzz

    smallbuzz Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Embrance, what you just described is called a database row. Why do I get the feeling that you are not convinced that database is good and flat files are so 1995.
     
    smallbuzz, Jan 26, 2007 IP
  8. toby

    toby Notable Member

    Messages:
    6,923
    Likes Received:
    269
    Best Answers:
    0
    Trophy Points:
    285
    #8
    mysql is a Relational Database. It is not a files. its benefits include fast retrieval and the ability to do join query between different table.

    I would not go to flatfiles for storing permanent data. BUT flatfiles is good for daily batch file that may be used for transporting data from one system to another
     
    toby, Jan 27, 2007 IP
  9. prilep

    prilep Well-Known Member

    Messages:
    3,852
    Likes Received:
    228
    Best Answers:
    0
    Trophy Points:
    185
    #9
    Its much better to use mysql because if you use flatfiles you will need a file to store all the information. The more information the slower the site will be.

    - Prilep :)
     
    prilep, Jan 27, 2007 IP
  10. pr0xy122

    pr0xy122 Peon

    Messages:
    1,649
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #10
    management is so much more effective with a database, I recommend MS.
     
    pr0xy122, Jan 27, 2007 IP
  11. aspcode.net

    aspcode.net Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Just wanted to add

    the MySQL server also handles locks etc (multiple users etc). Two visitors accessing the same flatfile at the same time (one might be updating another reading) will give you trouble
     
    aspcode.net, Jan 30, 2007 IP
  12. Embrance

    Embrance Well-Known Member

    Messages:
    192
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #12
    Thanks guys for your input on this:
    1)I know the way i described it,is almost the same way a table looks. I have been working with SQL DBs for like 2 years now.
    2)What i want to make is a very simple News script with an css file to control the look. The script will have some predefined variables,and will know where to get the data from already from the very beginning.Currently what i was thinking:
    store in each flatfle like 100 entries,no more-no less. Use a way to make folders and every 100 entires create a flatfile to hold the neext 100 nes items.Or i could just have only IDs in the flatfile and point to a static HTML wich will be generated using the news system.
    So the structure would be:
    ID|URLtoHTML|
    I think this will be easier though.

    Im not surre what type of method to use to access files,but i have been studying the way NavBoard works for some weeks now. You should check it out.Maybe the best script that uses FF,and actually works,lol.
     
    Embrance, Jan 30, 2007 IP
  13. circuscircus

    circuscircus Peon

    Messages:
    240
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Use MS SQL, I like it more than MySQL but either way, both is better than flat files
     
    circuscircus, Jan 30, 2007 IP