permaculture playing cards*
The moose likes Object Relational Mapping and the fly likes Table Design Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Table Design Question" Watch "Table Design Question" New topic
Author

Table Design Question

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

This may not be an ORM specific question but since I am asking in the context of "Java Persistance with Hibernate" I think this forum is as good as any...

In "JP w/H" the authors talk about compositions and they give an example of a USER table with colums for ADDRESS in the USER table. And then using a composition mapping to map the ADDRESS data to a seperate Address class that is a property of the User class. Address is a value type and User is an entity. (JP w/H p. 184,185).

While I understand the concept, other than legacy databases, I don't think I would ever impement the association as such. I would want a seperate table with it's own identity for Address and use a ManyToOne type of association. Am I naive to assume this is preferred?


GenRocket - Experts at Building Test Data
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Yes, you are correct in that in the real world of today you would design Address as having its own table, and that for that example Legacy databases might have address info in the User table.

And it is being used just as an example to should how to map/annotate a Composition.

Later on you will probably see a better example with a MonetaryAmount object.

So just look at it that way and say oh I see @Embeddable and @Embedded or <component....>

I say this everytime when teaching the Hibernate classes.

Mark
[ January 28, 2007: Message edited by: Mark Spritzler ]

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Thanks Mark. I assumed as much. I just wanted to make sure I wasn't missing something. I'm sure as I continue through the book I'll have some more of these types of question.
 
GeeCON Prague 2014
 
subject: Table Design Question