1

I would like to store some options in MySQL as a sigle integer as it's described in C & PHP: Storing settings in an integer using bitwise operators?. However I have more than 100 options to store (2^124 int?) so I'm wondering if there is a better way to store such a big number (64-base number as a VARCHAR?) and a way of checking chosen settings.

For your interest - I try to update some simple Reagents Databese I've made for my work on university, and I like to add GHS Statements to my records.

Maybe I'll simply divide the list into smaller chunks?

Thanks in advance.

aynber
  • 22,380
  • 8
  • 50
  • 63
  • 5
    not gonna say "don't do that", but i'll say it will be a nightmare to maintain. I've used these "monsters" before. – Alex Tartan Jul 04 '17 at 14:46
  • 2
    Is there any reason why a simple 100 character field won't work? After all these days storage is cheaper than your sanity! – Nigel Ren Jul 04 '17 at 15:19
  • 1
    Even [the dedicated data type](https://dev.mysql.com/doc/refman/5.7/en/bit-type.html) falls short but, well, I guess you can always have two columns ;-) – Álvaro González Jul 04 '17 at 15:25
  • 3
    This is really a bad call. Make another table with options, and a "join table" to relate the records to these options. Bitfields are a total nightmare to work with outside of a strictly C context, Alex Tartan isn't wrong. – tadman Jul 04 '17 at 16:59
  • Thank You all, I think I will choose a char array ;) – Piotr Sawicki Jul 04 '17 at 17:53

0 Answers0