Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple columns UNIQUE constaint with relations

 
ruben depuben
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a link table that links Profiles to Tasks and stores some additional information belonging to the link. I am using a surrogate primary key in the link table.

ProfileTask
profiletask_id (pk)
profile_id (fk)
task_id (fk)
a_field (varchar)
b_field (varchar)
c_field (varchar)


In my mapping document I am enforcing a UNIQUE constraint on the profile_id and task_id combination, using <properties name="naturalKey" unique="true">. This works! All I really want to know is if this is the intended way to enforce the uniqueness of the natural key (profile_id, task_id), when using a surrogate primary key (profiletask_id).

Thanks.







 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic