I'm new here and i wonder if this is the right place to ask this question. Basically i'm in the process of developing a library system demo and plan to use hibernate for my DB layer. what i have planned to do is to convert my object model into relational. The main issue that i have concerns inheritance.
I have so far identified 2 inheritance hierarchies involving the users of the library system and the library items. I have a normal LibraryUser(student), MemberOfStaff(lecturer/prof) and Librarian who all inherit from LibraryMember. I also have Book, Journal, CD-ROM and Tape who all inherit from LibraryItem.
One of the main problem is should i map all the inheritance hierarchies to a single table or each concrete class to a table or each class to a table? In case of hibernate i think that is a case of using either sub-class or joined-sub-class or just class.
At the code level(domain object) my confusion lies here:
[b]either[/b]
publicclass user
{
.....
Set borrowedBooks;
Set borrowedCDs;
....
settters/getters
.......
}
in the above case i think i'll be using separate tables and it'll be easier to add items like books,journals..
[b]OR[/b]
[code] public class user { ..... Set borrowedLibraryItems; .... settters/getters ....... }
[/code] In this case i'm representing borrowed items using the superclass. With this scenario how would i insert/retrieve a specific item(as a libraty item might be a book journal/book/cd ?).
the other thing in this dilemma is that any one(staff and librarian) except the student can borrow a journal.
So my main questions/confusion, should i map to a single table for hierarchies or several tables and should i maitain references using the sperclass or subclasses?