In order to solve
The number of rows and columns of these two example isn't the same and can vary in time: next quarter, the company can hire a new salesman.
back in the old days where we use relational tables we would decompose it in two tables
period | salesman | sales
2013.Q1 Sven 1200
2013.Q2 Sven 1350
2013.Q3 Sven 2487
2013.Q4 Sven 4570
2014.Q1 Sven 4785
2013.Q1 Kenneth 4500
2013.Q2 Kenneth 900
2013.Q3 Kenneth 784
2013.Q4 Kenneth 4512
2014.Q1 Kenneth 3451
salesman | id
Sven L Sven
Kenneth W Kenneth
this is not normalized up to 5th normal form but it would do.
you could use Cassandra or Mongo, Cassandra you could use super column families that allows you to create columns on the fly and MongoDb it isn't a rigid structure you are saving only json objects you could be saving only quarters like so:
{
"quarter" : "2013.Q1",
"salespeople" : [
{"salesman": "Sven", "sales" : 1200},
{"salesman": "Kenneth", "sales" : 4500}
]
}
and next year
{
"quarter" : "2014.Q1",
"salespeople" : [
{"salesman": "Sven", "sales" : 1200},
{"salesman": "Kenneth", "sales" : 4500},
{"salesman": "Somebodyelse", "sales" : 100000}
]
}
you can do both ways but relational way is so much easier