blob vs text in forum
Asked Answered
I

1

5

I'm writing a forum website, but i am having a problem with designing the database to hold the posts right now. From what I have read, phpBB 3 stores the user posted data as BLOB, and some store data as text. Is there an advantage that one would have over another? What about max characters if one were to store the data as text? I have never retrieved BLOB data from database and parse it to text (or whatever data it is meant to be for that matter) but I think learning how to use it would be interesting.

The text data for the post will be utf8 encoded. I'm using MySQL database.

Also, how would you allow uploading images for the forum and should the images be stored as part of the database, like in a BLOB for example, should should it be stored as individual files?

Any recommendation/suggestions are welcomed.

Imprisonment answered 19/4, 2012 at 8:53 Comment(3)
If you have encoding in game, then you use text. If you store binary data, such as contents of a file to the database, you use a blob. There's no reason to use blob for forum posts.Lactate
Related: https://mcmap.net/q/1673262/-store-text-in-blobFlunky
I read that before, but it didn't answer my question. So do most forum sites store them as text data and then retrieve them from database? That was what I was thinking of doing but I became unsure once I read about BLOB and phpBB.Imprisonment
G
9

Text and blob are nearly identical, the main difference is that you have to care about the encoding yourself when using blob. On the other hand you will be forced to use the encoding of a text field... Storing files in the database has some advantages and disatvantages:

Advantages:

  • Backups and switches to another server are easier to achieve
  • No need to add another method to access the files beside the database

Disadvantages:

  • Accessing an image means retrieving it's bytes and maybe storing that as temporary local files and may be more complicated
  • File systems are simply faster due to lower overhead

The decission is yours, the most opinions that I have heard so far are to store the pictures as files; but that are opinions, try to base your decision on your projects needs.

Ganymede answered 19/4, 2012 at 9:29 Comment(2)
is there a function in codeigniter to allow the user to upload images?Imprisonment
I personally have no experience with codeigniter, so can't tell. Perhaps this link may help: linkGanymede

© 2022 - 2024 — McMap. All rights reserved.