Book a Demo

Author Topic: Foreign Keys  (Read 10374 times)

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Foreign Keys
« on: November 20, 2007, 02:52:11 pm »
I've created two tables with Primary Keys, and a potential Foreign Key in one of them. I'm trying to follow the Help instructions for indicating the FK, but when I pop-up the context menu for the Association, the FK dialog is empty, i.e., it doesn't show any of the columns in either table. What am I missing?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Foreign Keys
« Reply #1 on: November 20, 2007, 03:42:59 pm »
Frank,

I think this changed a bit when version 7.0 came out.

Try creating a new diagram. When you do this, pay attention to the diagram type in the new diagram dialog. Select Extended in the left hand list, and Data Modeling from the right.

Let us know if this makes the difference.

David

PS: Make sure you draw the association in the right direction, if you've not done so yet. (Try both)
No, you can't have it!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Foreign Keys
« Reply #2 on: November 20, 2007, 04:15:39 pm »
Hi Frank,

Make sure the two classes are stereotyped table as the primary stereotype and that both have the database type assigned and that the two values are the same!

This is the minimum pre-requisite for the FK dialog to be enabled...

Let us know if any of the above wasn't in place... IF you still can't bring it up, give us a synopsis of what you have done...

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

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Foreign Keys
« Reply #3 on: November 20, 2007, 06:13:27 pm »
A synopsis would be good, because I can't NOT create the Foreign Key, and I've tried it heavy-handed in a simple, clunky old Class diagram too.

Frank, could you clarify what you mean when you say you have created two tables with Primary Keys and a potential Foreign Key in one of them? The process creates a new Foreign Key, so I'm not sure if you are trying to grab something that already exists? Not that that leads me to any logical explanation of the problem,though...
« Last Edit: November 20, 2007, 06:16:05 pm by RoyC »
Best Regards, Roy

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Re: Foreign Keys
« Reply #4 on: November 21, 2007, 06:05:59 am »
I have done all that (I think :-) I.e., I'm using Data Modelling for the diagram type, both tables are Stereotyped 'table', one has a primary key. I have tried the other both with the same key name (but not marked primary) and without. I have tried creating a new diagram from scratch, but it behaves the same. To be clear: the problem is not that I don't get the FK dialog, but that it comes up completely empty, i.e., it doesn't display any fields at all.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Foreign Keys
« Reply #5 on: November 21, 2007, 06:18:32 am »
Frank,

Let's check the obvious things.

Are you absolutely sure you have a database set on both tables? Have you verified that the data type of the key fields in both tables are the same?
No, you can't have it!

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Re: Foreign Keys
« Reply #6 on: November 21, 2007, 06:20:38 am »
No, I have not specified either a database or a data type. Both are unknown at this stage.

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Re: Foreign Keys
« Reply #7 on: November 21, 2007, 06:22:05 am »
...but that does seem to be necessary :-(

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Re: Foreign Keys
« Reply #8 on: November 21, 2007, 06:28:23 am »
It also adds four(!) labels to the Association.

All I want is to prefix 'FK' to the field. I take it, this is not possible?

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Re: Foreign Keys
« Reply #9 on: November 21, 2007, 06:29:24 am »
Now that I've added the database and the datatype, is there any way to get rid of them?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Foreign Keys
« Reply #10 on: November 21, 2007, 07:24:16 am »
No, I don't think so.

I think you are a victim of a side effect of how they key definition dialog works. Since it is enforcing the same data type on a relation, you need to specify something for the type; to do so you've first got to specify a database.

It sounds like you are trying to create a conceptual model. If so, try building it as a class model, without table and column stereotypes - since EA will look for these two stereotypes. You can then do some kind of transition to a logical model, perhaps with a transformation.

Perhaps you are trying to model a schema for a different DBMS. If so, you can add your own DBMS definition using the Settings | Database Datatypes dialog. EA's support for this is limited, but still much better than nothing.

David
No, you can't have it!

thomaskilian

  • Guest
Re: Foreign Keys
« Reply #11 on: November 21, 2007, 07:25:23 am »
Context menu from package / Code Eng. / Reset DBMS options

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Re: Foreign Keys
« Reply #12 on: November 21, 2007, 07:31:00 am »
It won't let me reset the DBMS to 'nothing'.

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Re: Foreign Keys
« Reply #13 on: November 21, 2007, 07:31:32 am »
Yes, I want a conceptual model of a relational database. I simple Class diagram would suffice, but I would minimally like to be able to specify the keys and relationships.
« Last Edit: November 21, 2007, 07:36:39 am by frankk »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Foreign Keys
« Reply #14 on: November 21, 2007, 07:46:17 am »
Frank,

Try the class model, with some (perhaps stereotyped) associations. You can transform these as well as the rest of the model.

Perhaps you can use roles in the associations to specify the participating fields.

David
No, you can't have it!