File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes ORM for normalization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "ORM for normalization" Watch "ORM for normalization" New topic

ORM for normalization

Joseph Marques

Joined: May 01, 2005
Posts: 12
Recently I came across a database developer that didn't like to normalize. I wanted to use Hibernate to create an object representation of that data, but it was extremely difficult because things were very flat. Are there any handy tricks that anyone knows of to overcome scenarios like this? Any insight would be appreciated.
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
Your best bet may be to ditch the database developer.

If that's not possible and you can't work with him to revise the database schema, you could try creating views to provide your application with a normalized version of the data.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

There are many times is it good in production environments to throw out normalization, such as when the performance hit of joining the tables vastly exceeds the performance hit of maintaining the denormalized structure.

As Scott said though, you can use Views and/or Triggers in a db environment to automate some of these tasks to make your data appear normalized or denormalized when it isn't.

Hibernate, like JDO, does support inheritence mappings (vertical, horizontal, flat) and if the data is as difficult to work with as you say, applying one of these patterns might help. Ultimately, if the data is too forgone for object mapping tools, then your best bet is to restructure it.

[OCA 8 Book] [Blog]
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
Yes, I agree completely. Sometimes normalization is not desirable.

Especially when the ratio of updates to reads is very low and join performance is an issue like in a reporting application.
I agree. Here's the link:
subject: ORM for normalization
It's not a secret anymore!