PDA

View Full Version : design question need a good advice


shoa
Jun 8th, 2006, 04:14 AM
Hello all

In my application, I design one-by-one relationship (one table-one object) between database and class object. That mean for each table, there is one class: student table - student class... course table-course class. The database is designed so that when i delete a student, the information of this student in other tables will be deleted.

Next, I created interfaces (StudentDao, CourseDao) and then I create implementation classes to get/insert/update data from database for each table. This is also one-by-one. That means each class will add, delete, or update data for only one table (using Jdbc. for example: "insert into student....").

From that, I have a "Manager" class for each object such as StudentManager class to add/update/delete a student or CourseManager for add/update/delete a course (using Dao interface).

To display/add/edit student in a form, I have a command object class called StudentCommandObject. In this class, i have getter and setter class such as getStudentName, setStudentName.....To display/add/edit a course in a form, I also create a CourseCommandObject class

I hope that you understand what i explain so far.

Everything is ok sofar :)

Now I need to display student summary. It includes student details and his course details. I already create student summary class that store both student details and course details.

It can be seen that I can not get this information from only one StudentManager or CourseManager. What should I do?

Should I have both StudentDao and CourseDao inside StudentManager so that I can get those information for my StudentSummary. For example:

class StudentManager{

private CourseDao courseDao;
private StudentDao studentDao;

public StudentSummary getStudentSummary(){
-get student details form studentDao;
-get course details from courseDao;
set
return studentSummary;
}

Or should I have both StudentDao and CourseDao inside StudentCommandObject so I can obtain those information ????

It canbe seen that I can get student summary from a join query such as "Select ..... from student, course where......." inside a . However, it will break my one table-one object-one in Dao implementation class that was already created.


Thank you for any help
sho