• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

composite key

 
nelson christos
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wondering whether its a good idea to have a composite key in our table.
Our case is like this
A voyage can have a lot of dailyCargoReports associated to it.
Now the dailyCargoReport table can have 2 columns
voyage_id <pk>
sr_no <pk>
which represents the composite key
OR
one id column represnting the PK and one FK to voyage_id

which is a better way to go for from hibernate perspective.

Thanks
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate can map both cases, now if you are in control of the database schema, I always use a surrogate pk key which is just ids.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic