views:

74

answers:

3
+1  Q: 

DB or flat file?

Hi there,

Just one little question. Shall i put the HTML textarea content into a DB or a flat file? The textarea content can be very long (like an article or a project).

Thanks for helping. Silvio.

+2  A: 

Use text type instead of string, varchar type in db.

Note:-Text fields in mysql are limited to 65kb

EDIT

OR You should look at using MySQL's LONGBLOB or LONGTEXT data type. They can store up to 4 gigabytes of binary or textual data, respectively.

piemesons
text is not necessarily a good option, as it is deprecated [MSDN source](http://msdn.microsoft.com/en-us/library/ms143729.aspx)
slugster
@slugster check edit part.. Is it fine?
piemesons
@piemesons - my bad, i shouldn't have assumed SQLServer, your mention of other db's and their types is perfectly valid. +1.
slugster
That's perferct for my purpose.
Silvio Iannone
+1  A: 

Database without a doubt.

There's not much point in flat files because when you start expanding which you will do then you have to create more files and it's easier to lose track.

Start with a database and when you grow you can do things much faster and more complex selections by using structured query language the name says it all.

RobertPitt
A relational database is not always the matching hammer for your nail...
joschi
+1  A: 

Here are some pros and cons off the top of my head (I've done it both ways with varying levels of success):

Database Pros

  • Well known model for reading / writing data.
  • If the rest of your application is based on a database, this solution fits nicely.
  • The db has concurrency mechanisms already in place.
  • As long as you back up your database, your documents are backed up to (and in sync with the state of your database).

Database Cons

  • Theoretically, it is less efficient to pull a file from a database than directly from the file system. The db server has to read from disk, translate into its network protocol, etc.
  • The serving of these files from the db is a potential scalability bottleneck if only using one database server.

Flat File Pros

  • Dirt simple operations: Write, Delete, Read.
  • Presumably low overhead. If serving from web, the server can just be pointed to the files.

Flat File Cons

  • You have to deal with concurrency operations (what if one user wants to write to the file while another is reading, etc). This may or may not be an issue in your case.
  • It's one more type of information to back up / keep in sync / maintain.
  • You have to deal with security of the files as a separate issue from the rest of the data in the database.
RQDQ