How to add a current string into an already existing list

Roy Smith roy at panix.com
Sun Nov 3 13:16:41 CET 2013


In article <bdm7fiF28rrU1 at mid.individual.net>,
 Gregory Ewing <greg.ewing at canterbury.ac.nz> wrote:

> Nick the Gr33k wrote:
> > I just want a mysql column type that can be eligible to store an array 
> > of elements, a list that is, no need for having a seperate extra table 
> > for that if we can have a column that can store a list of values.
> 
> Relational database systems typically don't provide any
> such type, because it's not the recommended way of storing
> that kind of data in a relational database.
> 
> The recommended way is to use a secondary table, as has
> been pointed out.

Most SQL databases allow you to store arbitrary data as an opaque value 
(i.e. BLOB).  So, one possibility would be to just serialize your list 
(pickle, json, whatever) and store it that way.  I've seen databases 
that didn't use BLOB, but just stored json in a string field.

The limitation, of course, is that the data is opaque as far as the 
database goes; you can't do queries against it.  But, if all you need to 
do is store the list and be able to retrieve it, it's a perfectly 
reasonable thing to do, and a lot more efficient than doing a join on a 
secondary table.

Normalization is for database weenies :-)



More information about the Python-list mailing list