Book a Demo

Author Topic: Do I need to select "Unique" box for a table's Primary Key?  (Read 3725 times)

lipmanc

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Do I need to select "Unique" box for a table's Primary Key?
« on: April 24, 2008, 02:02:55 am »
What is the purpose of being able to check the "Unique" box when setting a column as a table's Primary Key?  Will the Primary Ken not be unique unless the box is checked???

Craig

Torsten Binias

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Do I need to select "Unique" box for a table's Primary Key?
« Reply #1 on: April 24, 2008, 02:27:16 am »
Hi Lipmanc,

When I check "Primary key" EA disables the check boxes "Unique" and "Not null". So I cannot check or uncheck "Unique" while "Primary key" is checked. How do you do this?

I'm using EA 6.5 (Build 804).

(Unchecking "unique" on a primary key doesn't make much sense, does it?)

Best regards,
Torsten

lipmanc

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Re: Do I need to select "Unique" box for a table's Primary Key?
« Reply #2 on: April 24, 2008, 04:13:39 am »
You're right.  It doesn't make sense.  The PK should be unique, but in my models, the unique key does NOT get grey-checked, although the null box does.  If I check the Unique box, I get a UQ index in addition to the PK index.

If I create a new project, it works as expected.

Maybe there's something corrupt or a setting that needs to be set/unset, but I don't know which.  

Anybody else know?

Torsten Binias

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Do I need to select "Unique" box for a table's Primary Key?
« Reply #3 on: April 24, 2008, 05:09:48 pm »
Hi Craig,

Quote
(Unchecking "unique" on a primary key doesn't make much sense, does it?)

I guess I was wrong here. Consider a primary key that consists of two columns named id1 nad id2:

id1 ! id2
----+----
   1 !   1
   1 !   2
   1 !   3

As you can see the primary key is unique but the column id1 is not.

Quote
Will the Primary Key not be unique unless the box is checked???
So the answer here is YES.  :)

Furthermore I found out that EA disables "Not Null" and "Unique" when you check "Primary key" (as I already wrote) but enables them if you select another column in the "Column" list and then select the primary key again.

Quiet strange...