[clug-progsig] Storing large bitwise values in MySQL

bogi khangyi at shaw.ca
Wed May 23 08:49:48 PDT 2007


You can, just addslashes and you would be safe.
Now regarding country listings, you should have a list of countries, with 
respective ids, or just use the standard US,CA,AR,MX, designations, or use 
the three letter designations USA,CAN,etc... now to specify a one to many 
relationship, between one record and a set of countries, you may add a 
varchar(say 128) and stuff the county ids into it as a comma delimitted list, 
like this "US,CA,AR" or, to satisfy normalization requirements create a table 
that has the id of the first record, and the code of the country, and this 
table would be (not unique), so you pick your record, and all the records 
from this table that has your record id in them, getting all the country 
codes that belong to this record. In the first instance, you get the comma 
delimitted string, parse it using code and you are practically done. But you 
are breaking the normalization rules. 
Cheers
Szemir

On May 23, 2007 09:07, Nick Wiltshire wrote:
> Somehow Shawn and I accidentally took this thread off list (probably good
> because it made me feel stupid when Shawn told me to use a cross
> referencing table, which in retrospect should have been my first solution).
>
> I'm curious though, can you put arbitrary binary data into CHAR(32)?
>
> On Wednesday 23 May 2007 08:52, Roy Souther wrote:
> > I would not use a BLOB or a very large INT because at some point in time
> > you may want to use another database and that could cause problems
> > moving the code over.
> >
> > According to http://en.wikipedia.org/wiki/List_of_countries there are
> > 245 countries that you would need to identify so a string of 32 chars
> > would give you a bit field selection range of up to 256 bits.
> >
> > Regardless of if you use CHAR(32) or a BLOB or a very large INT you are
> > still going to have to code your own function to perform the logic on
> > the bit field and the data type does not matter.
> >
> > The question you need to ask is "Is speed and issue?" and if so then
> > maybe you should look at all three and see how speed will be affected by
> > the storage type and the logic function you write.
> >
> > On Tue, 2007-05-22 at 16:56 -0600, Nick Wiltshire wrote:
> > > Hi all,
> > >
> > > this might not even be the correct way to go about it, but I need to
> > > store a multiple-select value with the possible choices being the
> > > countries of the world.
> > >
> > > Should I use a BLOB, a _really_ big INT or go about it some completely
> > > different way?
> > >
> > > Nick
> > >
> > > _______________________________________________
> > > clug-progsig mailing list
> > > clug-progsig at clug.ca
> > > http://clug.ca/mailman/listinfo/clug-progsig_clug.ca
> >
> > Royce Souther
> > www.SiliconTao.com
> > Let Open Source help your business move beyond.
> >
> > For security this message is digitally authenticated by GnuPG.
>
> _______________________________________________
> clug-progsig mailing list
> clug-progsig at clug.ca
> http://clug.ca/mailman/listinfo/clug-progsig_clug.ca



More information about the clug-progsig mailing list