Your idea of mapping students to courses is correct, although 
you do not have to have a pk in the mapping table if a studentid and course id
row are unique which by the sounds of it they are. The pk is a composite. But if
you want a pk key then you can. 

As to updating these mappings then if a new course is added then just provide a 
add couseMapping function
with the 2 keys. The question you should ask youself is time versus money, if 
you have the time and the
project has the cash then provide crud routines for each ie update mapping, 
delete mapping, new mapping and
in you buisness object representing your mappings if you have them add a type 
field which contains
a value for update, new, delete etc.. This way your application logic can work 
out which routine to call.

If like many projects you do not have time, and you want a nice simple design 
then delete and insert as you have 
suggested. Do this in a batch transaction to minimise database interaction and 
you got a nice simple solution.

At your service layer if dealing with objects this should be simple. Add them 
to the batch as you iterate.
then execute the batch.

good luck

Steve


-----Original Message-----
From: Vamsee Kanakala [mailto:[EMAIL PROTECTED]
Sent: Tue 3/15/2005 11:11 AM
To: ibatis-user-java@incubator.apache.org
Subject: Several dumb questions
 
Hello,

This is more of a database design question than an ibatis question, I 
hope you guys don't mind :) Here goes:

I have a table called students, and students can be assigned to several 
batches ('course' would be a better name, I think). So, I'm using a 
students_batches_map which basically contains  and id(primary key), 
student_id and batch_id.

First of all, is this a good idea? Is there any better way I can express 
such a relation? Second, if I have to update the number of batches a 
student is associated with, I can think of only one way: drop all 
batches a student is associated with and insert new selections again. 
Again, is this a good idea?

Finally, I'm having to iterate through the list of batches and insert 
each record into the students_batches_map. Is there a better way?

TIA,
Vamsee.


This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

<<winmail.dat>>

Reply via email to