Norse
Norse

Reputation: 5757

MySQL Multiple Columns vs Single Column for speed/optimization

I'm working on a database that describes different physical characteristics of certain people.

My question is, would performance be quicker/less of a workload to have multiple columns setup like so:

HAIR | EYES | HEIGHT | WEIGHT
brwn | blue | 5'9"   | 150

Or have a single column separating the data with delimiter, like so:

ATTRIBUTES
Hair: Brown,
Eyes: Blue,
Height: 5'9",
Weight: 150

Does one have an edge of the other?

Upvotes: 1

Views: 145

Answers (2)

Rob
Rob

Reputation: 12872

The performance difference would be minimal, if any. The problem with delimiting the data in a single column is that it makes it more difficult and resource intensive to perform a search. What if you want to find all people that weight between 150 and 160 and have blonde hair? Wont be that easy with it all stuffed in a single column.

Upvotes: 1

JoelFan
JoelFan

Reputation: 38704

You should have separate columns for each attribute. Otherwise why are you even using a database?

Upvotes: 2

Related Questions