Jump to content
  • 0

How To Create A Unique Index On A Composite Key


bdrhoa

Question

I have a join table with just the 2 id fields to link a master record to its detail records. For example, 1 Quote (tbl_quote) can have multiple Tags (tbl_tag) so the QuoteCategory table has quoteID and tagID.

I don't want to allow duplicate records in the QuoteCategory table. I only want to allow any Quote+Tag combination to be enter once. So how do I create a unique index on the combination of quoteID + tagID?

 

 

2016-10-22_1953.png

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello. Use javascript on the DataPage to concatenate the fields you want in your composite key and create a new field in the table to store the concatenated value. Set that table field to Unique and you should get an error when you try to save a record that duplicates the composite field.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...