-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Schema/Mapping Design Considerations
PostPosted: Mon May 28, 2007 11:12 am 
Newbie

Joined: Mon May 21, 2007 10:31 pm
Posts: 2
Greetings,

I have some design questions regarding a multi-user application I am developing using Hibernate 3.2.2.ga.

When a user logs in, they are presented with their 'buddy list', a list of other users they have established a relationship with. In this table, among other columns, there is a column for displaying the date the logged-in user last sent that buddy a message, and another column displaying the date that the buddy last sent a message to the logged in user: 'last sent date' and 'last received date' essentially.

I am brainstorming the best way to design the schema and mappings to retrieve the buddy list with easily/quickly accessible message dates. In the full collection of messages for any given buddy, there will be many messages sent/received between a buddy and different users, which are irrelevant to the logged-in user, so I would like to limit the messages retrieved to be either to or from the logged-in user. Furthermore, I only need the last one sent and the last one received, so all others sent/received previously are also irrelevant to this data.

So far, all I can come up with is the following choices: have 2 collections of messages on my user object, one for sent and one for received, and when retrieving buddy lists 1. create a query that takes the logged-in user id and only retrieves buddies' messages that are to or from the logged-in user, with the largest date value 2. retrieve all buddies messages everytime and sort/iterate on the client side (very undesireable).
3. store the last sent/received dates only in a seperate join table between users and messages and update the fields everytime a message is sent. the table would act as a summary of all messages sent/received between two users.

Is there a better way I am overlooking?? Thanks. t-


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.