0

A simple question. Suppose I have 4 numbers that describe a box. Should I add them in the form of: box:{top, bottom, left, right} or keep them as 4 separate fields of the document?

I would appreciate a reason to, or not to, choose or not choose a particular one. Bare in mind this will used everywhere. Unless I shouldn't !?

Discipol
  • 3,137
  • 4
  • 22
  • 41
  • how does a number represent a point? do you mean a coordinate pair? – Asya Kamsky Jun 01 '13 at 07:18
  • Take the 4 corners of a box. any two points on a side have 1 value in common. thus its more efficient to store them as 4 numbers, each representing a side. to get the top-left corner, for example, consider the top number value and the left number value. – Discipol Jun 01 '13 at 07:41
  • 1
    ah I see - the box sides are parallel to your x and y axes. – Asya Kamsky Jun 01 '13 at 07:45
  • Well, yes :D nicely put. what about the problem at hand? – Discipol Jun 01 '13 at 08:30
  • IMHO I would always store data in the format that will allow the most flexibility when querying - do you know how you will be accessing this data? I don't think a generic answer really exists... – Asya Kamsky Jun 01 '13 at 08:48
  • I will always ALWAYS query those values together. – Discipol Jun 01 '13 at 09:12

1 Answers1

0

Put them all into a single box: {top:1, bottom:0, left:0, right:1} style field as the two approaches are functionally equivalent but this way would let you more easily include/exclude the group of fields in projections when needed by just referencing box: 1 or box: 0.

JohnnyHK
  • 305,182
  • 66
  • 621
  • 471