Click here to Skip to main content
15,890,336 members
Articles / Web Development / ASP.NET

EventFeed Data Model

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
13 Jul 2012CPOL2 min read 8.7K   2  
A data model that captures events, subscribers and topics to provide a core data model for any event registration and timeline system.

As we mentioned in a recent post, we are going to be using BrightstarDB to create ready-to-go data models that can be used by developers in building their applications. First up is a data model that captures events, subscribers and topics to provide a core data model for any event registration and timeline system. All the code is available for use in the BrightstarDB github repository.

One requirement we often see for intranet based projects is the notion of an event stream that is personalized for each user. The concept is quite simple, subscribers subscribe to topics. Events occur at a given time and these events are classified by one or more topics. Events can come from many systems, (we don’t go into detail about how these events are captured). A subscriber timeline is a list of all events that are classified by the same topic(s) that a subscriber is interested in. More specifically, the subscriber will only see events that occurred when they were interested in a given topic. Finally, events have associated data. This data can be different for each event. By using BrightstarDB, we can combine a typed model for (Event, Subscriber and Topic) and also use dynamic features to capture the event data.

BrightstarDB was a good choice for this model as it allowed us to quickly iterate and try out new model ideas, and make use of the schema-less features of the underlying triple store.

We have defined a EventFeed service object that provides high level access to the functionality. It has the following operations:

C#
public interface IEventFeedService
{
    void AssertSubscriber(string userName, IEnumerable<Uri> topicsOfInterest);

    IEnumerable<IEvent> GetSubscriberTimeline(string userName, DateTime since);
    IEnumerable<IEvent> GetTopicTimeline(string topicId, DateTime since);

    void AssertTopic(Uri topicId, string label, string description);
    dynamic GetEventData(IEvent feedEvent);
    void RaiseEvent(string description, DateTime when, IEnumerable<string> topicIds,
                    Dictionary<string, object> eventProperties = null);
    void RegisterInterest(string userName, string topicId);
    void RemoveInterest(string userName, string topicId);
}

The data model consists of just three types: IEvent, ITopic, and ISubscriber, and is shown in the diagram below:

Image 1

We hope this model is useful to someone, either as is, or as a starting point for something bigger and better. Also, if you are looking at how dynamic and typed objects can live together, then check out the service method for RaiseEvent.

All feedback welcome to contact(at)brightstardb.com, or @brightstardb.

This article was originally posted at http://brightstardb.com/blog?p=267

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Norway Norway
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --