Chaddeus
Chaddeus

Reputation: 13366

How to optimize "user tracking"-type data in a NoSQL database like RavenDB?

I have a Member object which gets stored now. My service uses the Foursquare venues API to show places nearby the member. I'd like to start tracking the places they've visited.

I could add a property to the member like:

Member {
    public List<Place> PlacesVisited {get;set;}
}

But that would essentially be duplicating the Place objects already stored in the RavenDB. Plus the Member is used throughout the site, while the places they've visited would only need to be shown on one page. Wouldn't be a big deal if they only had a couple places visited, but once they start having hundreds, or more... I'd be pulling more and more data inefficiently (when not needed).

I could put the visited places in another object. Perhaps something like:

VisitedPlace {
    public Member Member {get;set;}
    public Place Place {get;set;}
    public DateTime WhenVisited {get;set;}
    ...
}

That doesn't keep me from duplicating data, but it does mean I'm not pulling all the places the Member has visited, when not needed.

Also, in the future I may be tracking more than just places visited... Is there a better way/pattern? I'm rather new to NoSQL, this is my first project using RavenDB. Thanks in advance!

Upvotes: 1

Views: 130

Answers (1)

Ayende Rahien
Ayende Rahien

Reputation: 22956

Chad, Is there any reason why you can't do:

Member {
    public List<string> PlacesVisited {get;set;}
}

And just hold the ids of the places he visited?

Upvotes: 2

Related Questions