Can I store multiple INT values in a single field in mysql?
- I can only suggest storing an array of int values in a single cell. But you have to write a function to extract - Mr. Black
- Yes, I also thought about it - Mr. Music
- You would say why this is necessary. and then on these "arrays" then they try to find something or something else to do with them and it turns out that they need to be done according to the NF by putting them in a separate table - Mike
|
1 answer
Not. Only one integer can be stored in an int cell.
UPD: for storage, you can use arrays (as mentioned above).
- MySQL arrays .... this is something new. you can of course serialize an array into text, but it will be extremely difficult to work with it - Mike
- @Mike, there is nothing heavy about it. Array in php, and in MySQL it is a string of variables separated by commas - Mr. Black
- Well, I say serialized into text. Only here we have a lot of questions on SO "I have comma-separated values here, and I want to check the referential integrity for them and still want to search and, while at the same time, I don’t go through the entire table, but I quickly found the index in millions of rows." therefore I say that it is difficult, for the database it is difficult, like it is not long to write ... - Mike
- So you better tell me how best to implement - Mr. Music
- In fact, you were told in a commentary on your question: “you have to do it in a separate table on the NF,” everything else is a perversion (in mysql at least, if it were postgresql, it would have been a different conversation), which in the future nothing good will spill over. On the other hand, it’s really better to describe the task, why you need it, then you can really recommend something based on your particular case. - Igor Karpenko
|