Flat Files

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

I read somewhere something about flat files and that got me interested... is flat files like a self written database where you store stuff instead of MySQL or any other invented/created database system?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9102
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Flat files are basically self written database structures that you store in files. Before MySQL I used to store everything in flat files. So for example, lets say you wanted to store a username, first name, last name, and ip address. Your flat file might look like this with each line being a separate entry, and pipes separating the fields:

Code: [ Select ]
Johnny|John|Smith|123.123.123.123
Mikey|Mike|Williams|124.124.124.124
Sarah|Sarah|Johnson|125.125.125.125
  1. Johnny|John|Smith|123.123.123.123
  2. Mikey|Mike|Williams|124.124.124.124
  3. Sarah|Sarah|Johnson|125.125.125.125


Then you would simply write a parser and separate each entry by the new lines, and each field by the pipes. You could then store them in associated arrays, or somehow use the data just like you do with a SQL database.

Generally the performance of using flat files will not be that great because everytime you access the database you are having to access the file which is stored on the hard drive. Accessing the hard drive is extremely slow and if you get high traffic you will likely encounter very high loads on the server due to all of the disk access you have to make.

It is also a pain if you decide later to change your flat file database structure, and you would most likely need to write scripts to help automate any changes you make to the structure.

Overall I would probably stick to using a SQL database due to the increased performance and ability to change the structure relatively easily.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

I'm not going to create my own database :shock: I just read somewhere about flat files and wasn't sure what it was.

Thanks for clarifying that for me.
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

So its kinda like a database.txt file or how is something like that applied? kinda sounds unsecure.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Flat files are basically what today's databases evolved from. You can think of a "database server" as a program someone has been writing for years which does all sorts of little tricks to improve the performance of flat files. Tricks such as keeping frequently requested data in memory so it doesn't have to read from the disk.

Technically, a "database" is still a flat file (with the exception of something such as MySQL's "MEMORY" table type) but the database server keeps commonly requested pieces of data in memory and only writes to the file when it needs to get something it doesn't have cached, or when it needs to add new data.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

Oh I see... that makes sense. Thanks for clarifying that for me... that was actually an interesting read.
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

nice history lesson, but we need something more secure as SQL can not be the most secure at times.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6254
  • Loc: Seattle, WA

Post 3+ Months Ago

SQL is just a query language; how would you make it 'more secure'? It's the job of the application to secure access to its database, not the job of the database itself.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 30 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.