all in all… saving in a normalized database method has many advantages.
Firstly, you can keep the tags indexed within the db… which is more efficient than constantly sorting arrays.
Secondly, you save space… potentially huge amounts of space.
Third, you can mass ‘rename’ a tag…. for example, ‘coool’ > ‘cool’.......just edit one record in the DB, and every instance of that tag changes.
Fourthly, you can use the database of tags for other things too…
I have ‘tags’ and ‘files_tags’, but you could also have ‘blog_tags’, ‘images_tags’, all as linking tables to the ‘main’ database tags table.
As a final example… let’s imagine you have 100,000 files stored… and each has an average of 3 tags at 8 characters each.
Thats’ 24 characters + 2 for commas, for each file.
which comes to 2,600,000 characters of text… which is roughly translated at 2.4MB.
using a db, with a linking table, each tag reference is just 2 integer numbers.
2 x 3 = 6 numbers stored.
6 X 100,000 = 600,000 which is 0.57MB
As far as flexibility goes… using a normalized database is still just as flexible, you’ve just got to get your head around the queries that you need to use to do what you want it to do.
Elliot