Reputation: 157
I am trying to take a user from a game and track their stats. Each user has their own stats, so needs tracked separately. This ends up with each user has one dataset, and each dataset has many data points. In code I end up with..
public class User
{
public string Name { get; set; }
public List<DataPoint> Data { get; set;}
}
public class DataPoint
{
public byte Month { get; set; }
public byte Day { get; set; }
public short Year { get; set; }
public Stats stats { get; set; }
}
public class Stats
{
//user stats, just numbers.
}
(I am using my own month day and year because I don't need the extras of DateTime.)
This works for storing everything in memory, I just can't figure out a good way to persist it. I've been trying to do it in a relational database(SQL). It is the list that is really throwing me off. Should the one table just have a bunch of references to keys of data points? Should just serialize it and store the serialized data instead? I spent some time researching how other people store data points but I couldn't find anything useful.
I am working with Entity Framework in C#.
Upvotes: 1
Views: 143
Reputation: 1284
If I have understood correctly, could use the following structure in a relational database, you'd use a foreign key on the dataPoint entity to reference the user that the dataPoint relate to. This assumes that the stats collection is pretty consistent.
Upvotes: 1
Reputation: 8036
Entity Framework
,Code First
,NoSQL
solution, try BrightstarDb.Upvotes: 1