Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Storing multiple value field in a MySQL database

by davido (Archbishop)
on Nov 25, 2013 at 19:52 UTC ( #1064283=note: print w/replies, xml ) Need Help??


in reply to Re^2: Storing multiple value field in a MySQL database
in thread Storing multiple value field in a MySQL database

Of course you can create one VARCHAR(512), or whatever field, cram a bunch of comma-separated-values into it, and parse them out later. You can do that. But that's not an effective use of your database. It prevents you from easily searching in-database for all users who are a member of "wizzards". Instead you will have to use "LIKE" clauses, which are less efficient, or slurp all records into your script and do your own processing.

SQL-style databases usually just use another table whenever a developer is tempted to cram more than one item into a given field. There's good reason for that.


Dave

  • Comment on Re^3: Storing multiple value field in a MySQL database

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1064283]
help
Chatterbox?
[marto]: too add to my RL to do list: "This USB hard drive is damp, do you think my photos will be ok?"

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2017-01-23 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (192 votes). Check out past polls.