2

I need to store a large string that represents music notation in text format. This string could be anywhere between a few lines to several hundred.

I need to store meta data about the string (eg artist, instrument etc) in a database.

I'm wondering, would it be better to store the large text string in a flat file or in the database?

I think if I store it in the database it might be easier to monitor concurrency issues etc... but then in a flat file it would be easier to scale.

Matt
  • 1,473
  • 2
  • 11
  • 13
  • I think you'd find a database solution is just as easy, if not easier, to scale. – mikegreenberg Aug 06 '10 at 13:35
  • longblob is max 4 GB, so if it gets bigger, use files. – mvds Aug 06 '10 at 13:39
  • (also, don't forget security, backup, replication, data integrity and a ton of other issues you don't have to deal with if you just keep the data together in one table) – mvds Aug 06 '10 at 13:40
  • good points thanks @mvds! I really don't think a file will be more than 4GB for a single song (after being compressed) so I think I'll stick with keeping it alongside the meta data in the db in one table. – Matt Aug 06 '10 at 13:45
  • @Matt: welcome, btw you may also read (and support my answer in) this thread where the same point was downvoted by some: http://stackoverflow.com/questions/3415418/how-to-avoid-unlink-security-risks-in-php/3415518#3415518 – mvds Aug 06 '10 at 13:57

1 Answers1

2

If you're already storing the metadata about the music in a database, then just store the string representation alongside it.

That way all your information is in a single place and you won't have to worry about retrieving data from two locations when a user wants to fetch it.

Justin Niessner
  • 242,243
  • 40
  • 408
  • 536
  • Yeah, I'm currently thinking that makes more sense - but if it's going to have a lot of implications further down the line managing the data then I may as well prepare for it now. Thanks for your answer :-) – Matt Aug 06 '10 at 13:36