Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I need help with setting up the models(associations), on this problem.Write an application which displays these events in descending chronological order, For example, they can choose to see every chat event as it occurred, or stats about chat events for a given day.

There are a few event types:

enter-the-room
leave-the-room
comment
high-five-another-user

Granularity: minute by minute

5pm: Bob enters the room

5:05pm: Kate enters the room

5:15pm: Bob comments: "Hey, Kate - high five?"

5:17pm: Kate high-fives Bob

5:18pm: Bob leaves

5:20pm: Kate comments: "Oh, typical"

5:21pm: Kate leaves

The user can select an "aggregation level" which allows viewing the chat events aggregated together so that a long span of time can be viewed quickly, for example:

Granularity: Hourly

5pm: 1 person entered

2 left

1 person high-fived 1 other person

2 comments

6pm: 3 people entered

1 person high-fived 3 other people

15 comments

Note You do NOT have to implement the actual chat functionality - I am only interested in how the data is sorted, aggregated and rendered.

share|improve this question
2  
This sounds like a homework problem, and (coincidence?) classes in the US just started last week. So, what ideas do you have so far? – Izkata Aug 26 '12 at 4:17

3 Answers

up vote 4 down vote accepted

One way to model this is to first analyze the events. For each event, we drive a verb that represents an event type. I assume that event types are finite. Once you have created the correct schema, you could use SQL to group events as you wish.

Examples:

5pm: Bob enters the room --> Event: Person Enters Chat

5:05pm: Kate enters the room -- > Event: Person Enters Chat

5:15pm: Bob comments: "Hey, Kate - high five?" --> Event: Person Makes Comment

We can assume that events occur withing a chat (or a chat session).

Each person causes 0,1 or more events to occur.

Each event affects 0,1 or more peresons.

This leads to the ERD below.

You need to decide how to represent special events For example:

  • Kate comments: "Oh, typical"

Would you consider that Kate is talking to Bob or the the entire group? This is something that you have to make an assumption for.

Also, consider this:

  • Suzan says good night everybody

Two concerns here:

  • How do you classify the event "says good night"? may be as a salutation?

  • Do you want to associate this event to everyone participating in the chat?

You can study some scenarios and define the events required and iron out those special cases before you finalize your model.

Note: The id columns here are assumed to be sequence numbers, yo may choose business keys instead.

enter image description here

share|improve this answer

Hmm, let's see.

Usually, the users don't customize settings (make good defaults, that's the trick), so let's see what information the user needs.

  • in some cases, users want to be notified if a certain person does something. The easiest part is "tell me if X is seen in the room [as I need to speak to him/her]" - if you've ever fallen in love through chat, you know it's pretty important :)
  • In other cases, there might be only the network effect which we want to see (3 people left together for a bar)
  • In other cases, we just want to see a summary of events after switching back to the chat (either focusing on the window again, or literally re-joining)
  • In other cases, as channel moderators or other "staff-like" persons, we just want to see stats on what happened in the chat

You should analyze facebook and chat clients (Adium, kvirc, mirc, xchat) on this, as well as IRC statistics bots and programs. For some (all of the mentioned) you can find even the sourcecode - like, check how adium handles event collation.

You have basically atomic events (protocol events), then you have the detailed events, and then the summarized events.

  • Protocol events aren't likely to be stored at all, they're analyzed by the detailed events processor. They live only in the memory as a standard protocol entity.
  • detailed events are what could be used by multiple subsystems to display and analyze. They're likely stored short-term, like, about a day, or last 100. Detailed events are processed "raw" events", and they're a short struct.
  • summarized events, which are stored for record-keeping, summarized events are in fact, processed detailed events.

I strongly suggest you separate display and storage of detailed events: you never know what data you need later.

If you want to collate events (like, "5 people left"), then you'll have to have a "detailed events"-display processor, which has a bit of memory, separated by types.

The collation could go either only-if-uninterrupted (A leaves, B leaves, then something else happens, then C leaves -> "2 people left, something, C left"), in a certain period (2 people left since you last checked in), grouped by type (A went offline, A came online, A went offline, A came online - result: A came online - example, Adium), or simply superpositioning (2 people like Dr House - example: Facebook!)

These are, in fact, storage strategies, so you could employ GoF design patterns here.

This processor might need to be able to overwrite its last displayed data (remember at least last line, and be able to change it to a collated version)

Search for files containing 'Event' in name in Adium's source perhaps

Hope this helps.

enter image description here

share|improve this answer

Decide on the basic unit(s) of data that your program will work on. In this case, it sounds like each chat event is an "atom" in the program -- you'd never need or want to retrieve just a part of a given chat event. Give that unit a name, like "remark," so that you start thinking in terms of that unit. From there, decide what attributes a remark should have (date/time, the chat session that it belongs to, the text of the remark, color code, the person that made the remark, etc.) and decide how you want to store them (array, database, etc.).

It seems like a database would be appropriate here. Tables might include users, chat sessions, and remarks. That'd let you easily retrieve all the remarks that are associated with a given chat, but you could also easily query for, say, the number of remarks posted between two times.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.