ANURAG GUPTA
ANURAG GUPTA

Reputation: 193

Efficient Format for storing a range of values in database

I am questioning the very orthodox method of storing(at least in my zone) the range of values in db in a format (i.e. 0:1:20;1:7:40). This rule can mean,


Now, I am a believer of change and therefore would like to know if there is some other way to store such data in database which would give me flexibility in coding it as well as would require less space than the JSON format.

Upvotes: 1

Views: 50

Answers (1)

Nina Scholz
Nina Scholz

Reputation: 386654

While you have ranges which are consecutive, you could omit start value (if it is always zero) and use just the length of the range.

1|20     first range is starting with zero and ending on starting + length
6|40     second range starting with end of the last range

Upvotes: 1

Related Questions