Forum Moderators: coopster & phranque

Message Too Old, No Replies

What is a flatfile database

         

mystery guy nz

7:25 am on May 3, 2002 (gmt 0)



Can someone explain to me what a flatfile data base is..

Thanks

littleman

8:49 am on May 3, 2002 (gmt 0)



Welcome mystery guy nz!
A flat file is usually a ASCII test file with some type of deliminator, commonly a pipe '¦', or a CSV, comma-separated value.

Many scripts use flat files because they are very handy for smallish data sets. Also, scripting languages like perl could easily slice and dice them.

Damian

8:50 am on May 3, 2002 (gmt 0)

10+ Year Member



A flat-text file (a .txt or .dat file for example, but could be any ascii file format), that contains data.
It's what you would get if you export an sql or msaccess database to a .txt format.

Usually one record per line, with a seperating character to indicate the columns. The first line may or may not contain the column names.

Example of the contents of a flat text database file, with the first line containing the column names:

name¦address¦mailinglist
joe¦joe@example.com¦yes
mary¦mary@example.com¦no
pete¦pete@example.com¦no

Olaf

8:50 am on May 3, 2002 (gmt 0)

10+ Year Member



Its a normal text (or binary) file that lists the data in a sequential manner.

Such as in space/tab/etc.. delimited way.

Its a very low tech quick way to keep data. Easy for a small amounts of information (such as under 50.000 rows) since the file gets paged to memory if being used.

But as soon as you start using any serious amount of data its structure becomes a showstopper. Insertions, deletes, sorts and such slow it tremendously down.

Such as
name1¦address1¦Town1¦country1¦planet1
name2¦address2¦Town2¦country2¦planet2
name3¦address3¦Town3¦country3¦planet3
........

or
name1 address1 Town1 country1 planet1
name2 address2 Town2 country2 planet2
name3 address3 Town3 country3 planet3

Damian

8:53 am on May 3, 2002 (gmt 0)

10+ Year Member



:) three replies in two minutes. Nice board huh ?

txbakers

12:30 pm on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



a great board - my first stop in the morning!

It is possible sometmes to create a pseudo-flat file within a relational database.

I had a relational DB that needed to read through 10,000,000 rows on the primary table, then make joins to other tables. Processing was a nightmare, so we decided to let the DB do the joins and create one table instead of reading from 7.

In essence we had a flat file, but the processing time was exponentially quicker.

kingkelly

7:46 pm on May 9, 2002 (gmt 0)

10+ Year Member



Hey, does anybody know of a perl tutorial to search a flatfile database? My delimeter is a bit weird...

sparrow

7:57 pm on May 9, 2002 (gmt 0)

10+ Year Member



>>Usually one record per line, with a seperating character to indicate the columns. The first line may or may not contain the column names.<<

For those that are more technologically challenge, this is I believe the way to explain it.

(edited by: sparrow at 8:05 pm (utc) on May 9, 2002)

littleman

8:04 pm on May 9, 2002 (gmt 0)



kingkelly
[wdvl.com...]
good tutorial, fat and slow html

willtell

8:29 pm on May 9, 2002 (gmt 0)

10+ Year Member



txbakers,

The answer is yes and you can also create a psuedo relational db from flat files.

You didn't give enough details from your example, but the number of rows is not the deciding factor in what you did. Other considerations are the number of rows returned for each query and the number of columns of information.

If you need more help let me know.

sun818

8:40 pm on May 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do a Google search on readcsv -- Free script that reads in flatfiles to output data. What better way to learn than to look at proven code? They also cover how to fake a relational database. ;)

kingkelly

6:25 pm on May 12, 2002 (gmt 0)

10+ Year Member



Sun: I tried that before. CSV databases are different than othre flatfile databases since they usually say the field name on the first line. My databse is seperated by "##". Thanks though! And thanks for the tutorial, im reading it right NOW...