List:General Discussion« Previous MessageNext Message »
From:Joerg Bruehe Date:May 14 2010 8:54am
Subject:Re: Array data type
View as plain text  
Hi Samrat, all!


Samrat Kar wrote:
> Hello,
> 
>  
> 
> How to store multiple values in a single field? Is there any array data type
> concept in mysql?

"Multiple values in a single field" would be an explicit violation of
the relational model (on which the SQL language is based) and cause all
kinds of trouble in your queries.

Ever and again, developers use some kind of encoding to store a
combination of values (like flags in a bit field) in one database field,
but in many cases this makes queries very hard to write, and may prevent
optimization of the SQL statement.

It depends on your application, especially on whether this field will be
used in search conditions ("... WHERE combined_field has flag_X ..."),
to decide about a sensible approach.
In general, I would prefer separate fields for different flags, and a
separate table for a truly multi-valued field (like multiple postal or
mail addresses for a person).


HTH,
Jörg

-- 
Joerg Bruehe,  MySQL Build Team,  Joerg.Bruehe@stripped
Sun Microsystems GmbH,   Komturstrasse 18a,   D-12099 Berlin
Geschaeftsfuehrer: Juergen Kunz
Amtsgericht Muenchen: HRB161028

Thread
Array data typeSamrat Kar14 May
  • Re: Array data typeCarsten Pedersen14 May
  • Re: Array data typeJoerg Bruehe14 May
    • Re: Array data typeMark Goodge16 May
      • Re: Array data typePrabhat Kumar16 May