Book a Demo

Author Topic: Unique constrains on multiple columns  (Read 2757 times)

jakubbukaj

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Unique constrains on multiple columns
« on: May 18, 2009, 05:41:34 am »
Hello,
Can you please give me an example how to create unique constrains on multiple columns in DB table? I was looking in EA on many places but still I can create unique only single column, not multiple columns. It would be very nice in case this constrains would affect generated SQL file too.

Thanks for help,
Jakub

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Unique constrains on multiple columns
« Reply #1 on: May 18, 2009, 06:38:50 am »
Hi Jakub,

My first reaction was to ask you to check the documentation. I then looked for the section you should read, only to discover that it is nowhere to be found. [Perhaps it is there, but it is certainly not obvious.]

Here's what to do, or at least what used to work...

Set up your table and columns, without the unique box checked. That is, unless individual columns also have to be unique, in which case you should check the Unique box on the columns dialog as you define such columns.

Once all the columns are defined, exit the table dialog (to be sure everything is saved) and invoke the Operations dialog for the table (you can use the F10 shortcut for this).

On the Change Operations dialog, click New (if necessary) and give your new constraint--remember that the unique column combination is a table-level constraint--a name. Then in the Stereotype drop-down choose unique (that will be the constraint type). Click the Save button to save the constraint. Now click the Column tab to set up the columns. For each column in the set choose the column name from the drop-down and click the Save button to add it to the list. Then click New to enter the next column. You can use the 'hand' buttons to reorder the list if required (perhaps on a later edit). You can save your work via the Close button at the bottom of the dialog.

That should do the trick.

HTH, David

[edit]Bug report submitted for the documentation issue.[/edit]
« Last Edit: May 18, 2009, 06:42:42 am by Midnight »
No, you can't have it!

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Unique constrains on multiple columns
« Reply #2 on: May 18, 2009, 04:25:46 pm »
The basic modeling structure of a database is the table, made up of columns. The process of setting up a table is built up through the topics of the Data Modeling section of the Help. The first piece of David's advice is found in the Create Columns topic.

The unique constraint on multiple columns is in fact an index, and is therefore documented (albeit very obliquely) in the Index, Trigger, Check Constraint topic, under the Create an Index subheading. That is where the second piece of David's advice can be found.

I will add some (I hope) helpful index entries on the two topics and a link between them as well.
Best Regards, Roy

jakubbukaj

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Unique constrains on multiple columns
« Reply #3 on: May 19, 2009, 04:25:13 am »
Thank you very much for your help. It works precisely as I needed.