Should I plan to parse/regex, for example, an entire url string retrieved from one field of a database table during a while loop of query results using PHP?
Or should I store segments of the data (directory, filename, extension) in their own separate fields and concatenate the results during a while loop of query results?
Assuming worst-case scenarios, what would the most effective overall approach be in terms of both speed and efficiency?
MySQL & PHP are the suspects in question
My general philosophy is that you shouldn’t have “compound” fields in your database. By this I mean where one columns contains two or more notional values.
So if you were only ever interested in “filename” then that’s a reasonable single value column. If however you are often concerned with file extension, path and perhaps other data then you would store those in three (or more) columns.
Perhaps the worst example of this I see is where people implode an array with commas and then store that in a single column.