So I've stumbled across a problem when using mysql. I im trying to store an array thats pretty massive, It contains data to a graph, It contains about 100,000 sets of numbers. Like ['36','22','35','47','52' etcccc],, I was considering to use Varchar and just using Serilaztion to store it but that seems to cap very soon and doesn't allow me to store that many variables. Thanks for the help guys.
Asked
Active
Viewed 35 times
-1
-
1Putting more than one value in a single database field violates the most basic premise of relational databases. (See [1NF](https://en.wikipedia.org/wiki/First_normal_form).) It's hard to say for certain without knowing the specifics of your situation, but in general, you'll want to split the array into individual elements and store each in its own row. – Alex Howansky Jun 13 '17 at 16:05
-
Yes, you'd probably have problems when your array grows above [4 GB](https://stackoverflow.com/a/13932834/13508). Whatever, as Alex points out, if you don't want to index or search the array then there's little benefit in using a database in the first place. – Álvaro González Jun 13 '17 at 16:05
-
So basically just create a new table for say "Ages", then as the array grows keep inserting new rows for each variable in the column?, thanks for the fast reply! – Daniel Cisneros Jun 13 '17 at 16:14
-
ahh my mistakes, im confusing columns over rows. I would need to create new tables for each user correct? – Daniel Cisneros Jun 13 '17 at 16:17
-
What's a `user`? – Strawberry Jun 13 '17 at 16:32
-
A user is a person who is signed up and stored on my database. I wanted to store more information(arrays). – Daniel Cisneros Jun 13 '17 at 16:34
-
1OK, well under those circumstances you wouldn't normally have one table per user. You might have a table of graph data, a table which says which data point belongs to which data set(s), a table of users, and a table relating users to data sets. I'm only speculating because I know nothing about your model, but what I've described is along the lines of a standard normalized design. – Strawberry Jun 13 '17 at 16:40
1 Answers
0
you can use BLOB, MEDIUMBLOB, LONGBLOB instead of varchar and store it with serialize() method
Here are some information about the blob memory limit

fxlacroix
- 557
- 4
- 18