I have a need to upload 4,000 small audios (~30 seconds long) not ringtones 🙂
Similarly I have 4,000 html files.
I came to know about mysql is the best way to work with such large quantities of data.
however I do not know how to work with mysql database, how to organize the audio & html files. if there is a working example then I would greatly appreciate your help.
I have a need to upload 4,000 small audios (~30 seconds long) not ringtones
Share
You can store files directly in MySQL using BLOB data types. However, the best way is to store the audio files in a directory, and then just store the path to the file in the database. This is because, after a certain point, it is more efficient to store files in a file-system rather than in a database.
So your table could be,
As it stands, you probably would find there wouldn’t be much of a performance difference because you are working with a small number of files – but for best practice and future scalability, put it in the file system!
Then to pull out the data from the database you could use a simple PHP script to query the database and pull out all the paths and print them to the screen as links. In the example below im using PDO for database access, but you could also use the more simplistic mysql_query() if thats how your accessing your db.
You would want to put your files in a publicly accessibly area on your web area e.g. in a folder assets/audio, and then just put a relative path in your database e.g. assets/audio/file1.mp3.