Book a Demo

Author Topic: Data modelling: removing primary key  (Read 3631 times)

skiwi

  • EA Expert
  • ****
  • Posts: 2081
  • Karma: +46/-82
    • View Profile
Data modelling: removing primary key
« on: November 23, 2009, 02:46:27 pm »
I added a primary key to a table that already had one primary key.

I then realised I didn't want to do that, and tried to remove it
(both by unselecting the PK check box, and by deleting the column).

In both cases I got the following error message.


Sorry this attribute is part of a foreigh key relationship.

The table had an association (connector) with another table, and EA has deduced the relationship.

Without deleting the connector how do I remove (this part of) the primary key.

I'm sure there is an easy answer, but it does not appear obvious.

Tia
Orthogonality rules
Using EA16.1 (1627) on Windows 11 Enterprise/64 bit. Repositories in SQLServer2019 DB Schema 1558.
WebEA on Pro Cloud Server 4.2.64

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Data modelling: removing primary key
« Reply #1 on: November 23, 2009, 03:28:30 pm »
Quote
I added a primary key to a table that already had one primary key.
[size=18]...[/size]
The table had an association (connector) with another table, and EA has deduced the relationship.
[size=18]...[/size]
Just to be clear, this table is the foreign (parent) table in a foreign key constraint?

When you say EA has deduced the relationship are you saying you DIDN'T explicitly create the FK information, and so the connector doesn't have the «FK»  Stereotype?

In any event, I was ONLY able to reproduce your problem when the «FK» had been explicitly applied.  Up till that point, I could add/remove PK columns in the foreign table.

However, once you create the constraint,  EA (correctly) says you can't remove the additional column once the constraint is in place.

What EA incorrectly lets you do (or at least it let me do) is to allow you to add the PK column when the constraint had been applied - without asking if I wanted to cascade the change.  Consequently, I ended up (as I suspect you did) with an asymmetrical «FK» dialog - which by definition is inconsistent - since it's conceptually invalid.

To get around the problem you'll have to remove the «FK» constraint, but you don't have to delete the connector.  Just use the Foreign Keys... menu item to delete the constraint.  Remove your spurious column then recreate the constraint.

File an official bug report about EA allowing the addition of the column to the unique key of the foreign table (it doesn't have to be a PK!) while the FK Constraint was in place.

HTH,
Paolo
« Last Edit: November 23, 2009, 03:30:30 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: Data modelling: removing primary key
« Reply #2 on: November 23, 2009, 08:27:55 pm »
Change the stereotype from "table" to something else.
This way the element changes dialogs and settings to becom a standard class in which you can either remove the faulty attribute or remove the sequence property from the former primary key.
Afterwards change the stereotype back to "table".

This should be doing the trick.

Oliver

skiwi

  • EA Expert
  • ****
  • Posts: 2081
  • Karma: +46/-82
    • View Profile
Re: Data modelling: removing primary key
« Reply #3 on: November 24, 2009, 01:02:22 pm »
Thanks.
I'll try to create a test case to report.
Orthogonality rules
Using EA16.1 (1627) on Windows 11 Enterprise/64 bit. Repositories in SQLServer2019 DB Schema 1558.
WebEA on Pro Cloud Server 4.2.64