Book a Demo

Author Topic: PKs set always as unique (BUG?)  (Read 16459 times)

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
PKs set always as unique (BUG?)
« on: August 22, 2007, 09:53:58 pm »
When creating tables in 6.5 version I had an option to make PKs not unique, which is the natural situation when a table has several PKs. In 7.0 it seems to be imposible.
This is very serius proeblm since we generate our tables from the design.
Is is a butg or is it something I'm missing?
Recursion definition:
If you don’t understand the definition read "Recursion definition".

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #1 on: August 22, 2007, 10:41:55 pm »
Quote
When creating tables in 6.5 version I had an option to make PKs not unique, which is the natural situation when a table has several PKs. In 7.0 it seems to be impossible.
This is very serious problem since we generate our tables from the design.
Is is a bug or is it something I'm missing?
Ummm...  Martin, there is ONLY 1 Primary Key per table.   ;)

Can you clarify if you are talking about multiple Candidate Keys or concatenated Primary Keys.

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

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #2 on: August 23, 2007, 01:30:01 am »
If you look at MSSQL (which is our DB) you can mark several columns as primery key then making the combination actualy PK and if you import is from DB to EA they all aper as PK  non-unique and a function iscreated which combined them all as PKs.The same way if you create a table and mark several columns as PKs you'll see EA indeed creates this function.

In my opinion it is the corect behavior, but even if it isn't and the current behavior is then it is not consistent, so it a bug.

I opened a bug any way.
Recursion definition:
If you don’t understand the definition read "Recursion definition".

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #3 on: August 23, 2007, 02:29:39 am »
Quote
If you look at MSSQL (which is our DB) you can mark several columns as primary key then making the combination actually PK
OK, Martin, at this point you have actually marked a set of columns are columns in a primary key.  You are therefore describing a concatenated primary key.
Quote
and if you import is from DB to EA they all appear as PK  non-unique and a function is created which combined them all as PKs.
No... The EA function defines the primary as a set of columns.  The PK marker against the column, ONLY categorizes it as a column IN a primary key.  I, too, was initially confused by this.  It's important that we (and Sparx) recognize this distinction.
Quote
The same way if you create a table and mark several columns as PKs you'll see EA indeed creates this function.

In my opinion it is the correct behavior, but even if it isn't and the current behavior is then it is not consistent, so it a bug.

I opened a bug any way.
As far as I can tell, the previous EA behaviour (as I last checked it - not recently) was correct.  The behaviour should be consistent both defining the key directly or reverse engineering.  As you remark, the current v7.0 behaviour is WRONG!
(FWIW, I suspect the bug occurs because if there is only one column in the primary key, the column should be marked as unique.  However as soon as there is more than one, the unique bit must be reset for all the columns - I suspect the code doesn't check this latter case)

By the way, Sparxians, from a theoretical perspective, the columns of a concatenated primary key should be non-unique and ONLY the combination of columns provide a unique "identity".  If any of the columns of the concatenated key is, itself, unique then you are violating one of the rules of relational design:  "The key, the whole key and nothing but the key"  :D

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

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #4 on: August 23, 2007, 02:36:56 am »
Quote
"The key, the whole key and nothing but the key"
 ;D

Sorry, I always have problems explaining my self. ::)
Recursion definition:
If you don’t understand the definition read "Recursion definition".

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #5 on: August 23, 2007, 02:53:39 am »
Quote
Sorry, I always have problems explaining my self. ::)
I was actually explaining to the Sparxians - you just got in the way...  ;)

It used to work fine! :o  Then, as Thomas Killian says, Featuritis set in...  ::)

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

thomaskilian

  • Guest
Re: PKs set always as unique (BUG?)
« Reply #6 on: August 23, 2007, 04:27:22 am »
Quote
... Killian ...

be aware my friend, I could kil(L)ian you!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #7 on: August 23, 2007, 12:31:12 pm »
Quote
be aware my friend, I could kil(L)ian you!
Apologies!  My eyes are getting old...  :-[  I won't be making the mistake again!  ;D

Paolo
« Last Edit: August 23, 2007, 12:35:44 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #8 on: August 26, 2007, 11:59:34 pm »
Quote
(... as soon as there is more than one, the unique bit must be reset for all the columns ...


FWIW, uniqueness of a column in a table is a property of the column not the key.  There is no reason that the world works according to Codd.  Therefore if a column in an existing table has a unique constraint, then EA should reverse it as a unique column.  FULLSTOP.

EA should not make assumptions as to whether the world is correct or not.

Given a specific domain, there is no reason why a table cannot have several columns that are unique across the entire tuple set.  Granted this may be sub-optimal in the long run, but this is a non-infrequent occurrence in real domains.  Consider t_MyFamily, could have a set of unique columns depending on the domain, such as birthdate, driversLicenceNumber, mobile number etc etc.  Consider t_BugTracker, could have two unique ID's myBugID, developerBugID.  In the real world Codd is not God. There is no reason why EA should infer relational "correctness" in interpreting reality.

bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #9 on: August 27, 2007, 12:40:11 am »
Regardless whatever any one here said is correct or no, you can not make in EA a non-unique PK - this alone is a bug!
Recursion definition:
If you don’t understand the definition read "Recursion definition".

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #10 on: August 27, 2007, 01:07:53 am »
Martin, no, by definition a primary key MUST be unique.  Its entire definition depends on its ability to "uniquely identify a single tuple in the dataset".  This (quotes part) is its definition.

bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #11 on: August 27, 2007, 02:45:39 am »
Quote
[size=0](... as soon as there is more than one, the unique bit must be reset for all the columns ...)[/size]
I wasn't as clear as I should have been - I was talking about creating new primary keys - but see below...
Quote
FWIW, uniqueness of a column in a table is a property of the column not the key.  There is no reason that the world works according to Codd.  Therefore if a column in an existing table has a unique constraint, then EA should reverse it as a unique column.  FULLSTOP.
Correct and accepted - my disclarity!  In addition, if I choose to make sub-optimal keys then EA can query me, but must take my direction.  Hence, see below...
Quote
EA should not make assumptions as to whether the world is correct or not.
Martin and I are complaining about the current v7 behaviour - which is different from pre-v7 and where EA IS making assumptions and getting them WRONG!
Quote
Given a specific domain, there is no reason why a table cannot have several columns that are unique across the entire tuple set.  Granted this may be sub-optimal in the long run, but this is a non-infrequent occurrence in real domains.  Consider t_MyFamily, could have a set of unique columns depending on the domain, such as birthdate, driversLicenceNumber, mobile number etc etc.  Consider t_BugTracker, could have two unique ID's myBugID, developerBugID.  In the real world Codd is not God. There is no reason why EA should infer relational "correctness" in interpreting reality.

bruce
I don't think I was arguing against what you've just said.  We were arguing against the current behaviour where EA creates a concatenated (or compound) Primary Key having each column marked as unique by fiat.  This is clearly wrong - never mind any Codd's wallop!  :)

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

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #12 on: August 27, 2007, 02:53:05 am »
Quote
Martin, no, by definition a primary key MUST be unique.  Its entire definition depends on its ability to "uniquely identify a single tuple in the dataset".  This (quotes part) is its definition.

bruce
Martin,

bruce is absolutely right.  

Actually, just as a Foreign Key is NOT a key but a Foreign Key Constraint, a "Primary Key" is really a Primary Key Constraint - which is often implemented by a unique index.  But as bruce says, it need not.  It is a corrollary that to "uniquely identify a single tuple in the dataset" you must impose a uniqueness constraint upon that tuple in the dataset.

I don't think the literature, nor training courses, make this subtlety explicit enough.

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

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #13 on: August 27, 2007, 02:55:31 am »
ref - the v6/v7 changes...

Maybe I got the wrong drift here.  I thought you two were arguing on the side of reveng assumptions.  

... still not going v7!!!

bruce
« Last Edit: August 27, 2007, 02:57:30 am by sargasso »
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: PKs set always as unique (BUG?)
« Reply #14 on: August 27, 2007, 03:04:24 am »
Quote
ref - the v6/v7 changes...

Maybe I got the wrong drift here.  I thought you two were arguing on the side of reveng assumptions.  

... still not going v7!!!

bruce
Ego te absolvo; in nomine Dateis, Coddis et Spirito Sparcis...   ;)

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