Storing a binary array in MySQL

I have an array of values ​​called A, B ... X, Y, Z. Pleasure, although it would have 26 columns in the table, I cannot help but feel that there is a better way. I considered creating a second table with the row id value from the first table, the identifier of the element in the array, and then the boolean, but it seems clumsy and confusing.

Is there a better way?

+3
source share
4 answers

The short answer is no. Long answer, it depends.

You can store binary data in several ways - abuse the number using BINARY or VARBINARY, using BLOB or TINYBLOB, etc. BINARY types will usually be faster than BLOB types if your data is known.

. , , , , , , OR, XOR NOT. , , . , .

, , . - , .

. , , - ? - ?

+6

?

, MySQL SET.

+2

You can try to save it as TINYBLOB or even UNSIGNED INT, but you will have to do the masking in your code.

+1
source

You can save it as a string and use the text manipulation functions to (re) create your array.

+1
source

Source: https://habr.com/ru/post/1702864/


All Articles