LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-07-2003, 04:33 PM   #1
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
Flat files vs Databases


I've been working on a little content managment system for a small site. It's pretty much just a test of ideas. Very basic stuff, login, post a message, message appears on main page, etc. What i've been thinking about is what the better *setup* would be.

Either keep all the required data (user name, the block of text, etc) in database.

Or

Keep only some of the data in the db, while the possibly big blocks of text will be stored as seperate files (storing the name of the file in the db).

So what do you guys think? Advice, opinions are all welcome!

cools
 
Old 09-07-2003, 07:33 PM   #2
eric.r.turner
Member
 
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint
Posts: 216

Rep: Reputation: 31
Putting all of your data in a database has the advantage of allowing you to control user access using the database's security mechanism instead of relying on lame *nix filesystem permissions. Definitely a better security model.

Given the choice between flat files and a database I almost always choose the database. If you do flat files you'll have to write all the code for querying, modifying, and adding data to the flat files... something the database does quite nicely for free. No sense in re-inventing the wheel.
 
Old 09-08-2003, 03:43 PM   #3
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Original Poster
Rep: Reputation: 30
True dat!

I was just think of the character size for the text to store. In the db i'd need to cap it, while if i store the text in a flat file i can make it any size, yet that would mean writing my own functions for modifying those files.
 
Old 09-08-2003, 04:05 PM   #4
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
Quote:
I was just think of the character size for the text to store. In the db i'd need to cap it
not true, on MySQL the TEXT and BLOB datatypes can be enormous, i think the total maximum is 4GB but in practice it is less than this, but still massive. certanly larger than anyone will type as a message.
 
Old 09-08-2003, 06:44 PM   #5
eric.r.turner
Member
 
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint
Posts: 216

Rep: Reputation: 31
According to the MySQL documentation, a LONGBLOB or LONGTEXT field has a maximum length of 4GB (well, one byte less than that actually.)
 
Old 09-08-2003, 09:23 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by coolman0stress
True dat!

I was just think of the character size for the text to store. In the db i'd need to cap it, while if i store the text in a flat file i can make it any size, yet that would mean writing my own functions for modifying those files.
If your concern is the physical size of the resulting
tables then I can give you some good & friendly
information (at least if the data base in question
is postgres, don't know how mysql handles that).
In PostgreSQL blob's and other large objects
aren't stored in a table consuming vast amounts
of storage for non-allocated data. Rather, PG puts
a flat file in the filesystems, and stores access
parameters to it in the data base table :)

Cheers,
Tink

P.S.: PostgreSQL rocks ;)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
databases varun_33 Linux - Software 2 02-03-2005 12:49 AM
Using flat files or tables with IPTables? tarballed Linux - Security 1 12-09-2004 04:08 PM
password protecting two files to two different databases on Apache? RKris Linux - Software 0 02-24-2003 06:04 AM
Sql databases CurlyMo Linux - General 5 02-12-2003 04:31 AM
Databases frankyboy4 LQ Suggestions & Feedback 1 08-09-2002 01:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration