-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Help w/ choosing Single Vs. Composite Primary Keys
PostPosted: Fri Mar 02, 2007 1:06 am 
Newbie

Joined: Thu Mar 01, 2007 11:16 am
Posts: 6
Hello Everyone,

I learned Hibernate about 2 days ago, from a short tutorial.

Here's some short intro about the database set-up:

I'm creating a new database from scratch. The database is being populated with automated feeds.

Each feed is stored in it's corresponding table in MySQL.

The notation for some feeds indicates the columns that need to be considered as primary key(s).

I was reading somewhere that having composite primary keys in Hibernate is suitable only for legacy databases and that , it's not a good idea to have composite keys.

I'm trying to decide whether to add an additional column to all these tables that indicates the primary key?

Or should I create a Hibernate composite key?

If a composite key is supposed to uniquely identify records in a table, then having a single auto generated primary key may not serve the purpose in my opinion.

Please advice what approach should be taken in this case...

I appreciate your input
Hibernate version: 3.3


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 5:23 am 
Newbie

Joined: Fri Nov 03, 2006 5:21 am
Posts: 14
Hi,

the question is, if you have many realtions between the tables and what you want to achieve with your Hibernate application.
If there exists many associations and you want to use inheritance and have a really complex datamodel, I'd use single values primary keys.

However, if there are no associations between the tables, composite primary keys are just fine.

And if you do not know all the requirements of your Hibernate application by now I would also go for single valued primary keys.

Regards,
Joern


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.