Book a Demo

Author Topic: Selecting Primary Key Does not Grey "Unique" Box  (Read 5631 times)

lipmanc

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Selecting Primary Key Does not Grey "Unique" Box
« on: April 24, 2008, 09:15:49 am »
In the past, whenever I set a column to the Primary Key, both the NULL and UNIQUE boxes are checked/grey.

Now, for some reason, only the NULL box is greyed when I select PK.  I can select UNIQUE and EA generates the UQ_ index, which is odd for a PK.  I'm okay ignoring the UNIQUE box for PKs, but I'm concerned that there might be something else going on, e.g., corruption.  

(If I create a new project, and set a PK, both NULL and UNIQUE boxes are checked/grey.)

Any suggestions?

Craig

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Selecting Primary Key Does not Grey "Unique" Box
« Reply #1 on: April 24, 2008, 11:31:06 pm »
I might because multi-field primary keys are supported by some DBMS engines. Any given field might or might not be unique, so long as the combination is.

Depending on how you use the table, you might want to explicitly create a unique constraint or key for individual fields beyond just creating the (compound) primary key.

Of course I'm just guessing here, but that's my initial reaction...

David
No, you can't have it!

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Selecting Primary Key Does not Grey "Unique" Box
« Reply #2 on: April 28, 2008, 09:50:20 am »
My understanding is that the Unique checkbox doesn't say "I'm declaring that this field is unique", it says "I wish to create a uniqueness constraint in my generated DDL".
The Sparx Team
[email protected]

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Selecting Primary Key Does not Grey "Unique" B
« Reply #3 on: May 26, 2008, 01:47:42 pm »
Quote
My understanding is that the Unique checkbox doesn't say "I'm declaring that this field is unique", it says "I wish to create a uniqueness constraint in my generated DDL".
Which defines this field as unique...

You need TWO constraints... A unique concatenated index may contain unique fields...  

So you need to be able (in the model) to define each column as unique (thus generating a column uniqueness constraint) and any index over the column set as unique - generating an index constraint.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Selecting Primary Key Does not Grey "Unique" B
« Reply #4 on: May 26, 2008, 08:24:19 pm »
The obvious case is a join table - between two other tables with a many-to-many relation. In the join table the combination of the two contributing foreign keys - the primary keys of the 'end' tables - is unique. But the two key fields themselves are not.

[Yes, I suppose you could insist they are unique. But combined with the not null condition you would end up with a very interesting relationship between the two tables. I'll leave this as an exercise for the student at home.]
No, you can't have it!