• 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.







 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!