A computer-implemented method for storing data of a data cube in one or more flat files (122a, 122b, 122c, 304), the flat files (122a, 122b, 122c, 304) stored in a tangible, non-transitory computer-readable medium, the method including: receiving a set of data records (302, 400), the set of data records (302, 400) having at least two dimensions, at least some of the data records (302, 400) each including respective data values for each of the at least two dimensions; generating a set of grouped data records (302, 400) wherein the dimensions are ordered by cardinality, each preceding dimension having fewer or the same number of data values than a subsequent dimension, the generating including grouping the data records (302, 400) into subsets according to data values of a first dimension of the at least two dimensions,, arranging the subsets of the grouped data records (302, 400) according to the data values of the first dimension and according to a sorting criterion, and arranging the data records (302, 400) of the subsets of the grouped data records (302, 400) according to data values of the subsequent dimensions Z of the at least two dimensions, such that data records (302, 400) of each respective subset of the grouped data are sorted by the values of the subsequent dimensions; and generating and storing at least one index compressed flat file (122a, 122b, 122c, 304) containing the set of grouped data records (302, 400); wherein a particular data record (302, 400) of the grouped data records (302, 400) includes a primary key that can be used to identify data of the particular data record (302, 400) in response to a request, wherein the primary key includes a field for each dimension and an element computed from at least one characteristic of at least two dimensions of the particular data record (302, 400), wherein the computed element of the primary key is a detail mask that includes a scalar representation of one or more detail levels, each detail level corresponding to a hierarchy (102, 104, 106) of a dimension of the data record (302, 400), wherein the at least one characteristics of the at least two dimensions include, for each of the two dimensions, presence of data at a particular level of the hierarchy (102, 104, 106), wherein grouping the data records (302, 400) into subsets includes sorting the data records (302, 400) according to the detail mask first, and then according to the fields for the dimensions, in the order that the fields for the dimensions appear in the primary key. receiving a set of data records (302, 400), the set of data records (302, 400) having at least two dimensions, at least some of the data records (302, 400) each including respective data values for each of the at least two dimensions; generating a set of grouped data records (302, 400) wherein the dimensions are ordered by cardinality, each preceding dimension having fewer or the same number of data values than a subsequent dimension, the generating including grouping the data records (302, 400) into subsets according to data values of a first dimension of the at least two dimensions,, arranging the subsets of the grouped data records (302, 400) according to the data values of the first dimension and according to a sorting criterion, and arranging the data records (302, 400) of the subsets of the grouped data records (302, 400) according to data values of the subsequent dimensions Z of the at least two dimensions, such that data records (302, 400) of each respective subset of the grouped data are sorted by the values of the subsequent dimensions; and grouping the data records (302, 400) into subsets according to data values of a first dimension of the at least two dimensions,, arranging the subsets of the grouped data records (302, 400) according to the data values of the first dimension and according to a sorting criterion, and arranging the data records (302, 400) of the subsets of the grouped data records (302, 400) according to data values of the subsequent dimensions Z of the at least two dimensions, such that data records (302, 400) of each respective subset of the grouped data are sorted by the values of the subsequent dimensions; and generating and storing at least one index compressed flat file (122a, 122b, 122c, 304) containing the set of grouped data records (302, 400); wherein a particular data record (302, 400) of the grouped data records (302, 400) includes a primary key that can be used to identify data of the particular data record (302, 400) in response to a request, wherein the primary key includes a field for each dimension and an element computed from at least one characteristic of at least two dimensions of the particular data record (302, 400), wherein the computed element of the primary key is a detail mask that includes a scalar representation of one or more detail levels, each detail level corresponding to a hierarchy (102, 104, 106) of a dimension of the data record (302, 400), wherein the at least one characteristics of the at least two dimensions include, for each of the two dimensions, presence of data at a particular level of the hierarchy (102, 104, 106), wherein grouping the data records (302, 400) into subsets includes sorting the data records (302, 400) according to the detail mask first, and then according to the fields for the dimensions, in the order that the fields for the dimensions appear in the primary key.