While I’m hoping to eventually switch to a newer, lighter, and/or faster DBMS (such as the aptly-named lightweight SQLite or the document-based Mongo- the latter of which would not present this issue), I am currently sticking to the standard MySQL system. Though I realize that any answer to this question may be one of opinion, I’m wondering how one would store serialized data such as an array or hash-map in a single column of a MySQL [or otherwise relational-based] database. Most data access would be executed via PHP, but I would like to store data in a standard format (i.e. JSON or binary hash-map- preferably the latter) rather than the plain-text of the dumped PHP array. The reason for this is that I may perform some data queries from Python, a compiled C/C++ application, or the command line.
Thanks.
Forewarning: this is my opinion only.
If you are planning to query the data from means other than the one storing it (e.g. store from PHP, query from C/C++ or even command line), I would strongly discourage you from storing the entire data structure in one column. Instead, I would suggest creating your data model to better support your queries (e.g. store a hashmap as a set of name/value pairs mapped to the id of the hashmap). Then create a model layer in the code to deal with conversion between the code layer and the database layer.
When you need to store the data into the database, from your PHP code, simply call corresponding methods/functions in your model layer, passing the hashmap. When you need to load the data from the DB, call the corresponding methods/functions in the model layer passing ID of the hashmap (or whatever the relevant identifier is) – and get the hashmap back.
This way, besides making it much-much easier to query the data later, if/when you change the database engine, all you will need to do is to update a few methods/functions in your model layer.