Author Topic: Data models - associations as foreign keys  (Read 1090 times)

Mark

  • Guest
Data models - associations as foreign keys
« on: December 12, 2001, 12:52:44 pm »
Hi,

is there any way of including foreign key associations as part of the primary key when data modelling? I don't want to have to manually add foreign keys as attributes...

Thanks,
Mark

sparks

  • EA Administrator
  • EA User
  • *****
  • Posts: 577
  • Karma: +0/-0
    • View Profile
Re: Data models - associations as foreign keys
« Reply #1 on: December 13, 2001, 04:01:03 am »
Hello,

I am not sure I understand your question.  A foreign key definition consists of a primary key (operation of stereotype PK) on table 1, a foreign key (operation of stereotype FK) and a connector joining the two table.  

We have written a PDF on the subject of creating foreign keys, you can download a copy of it from:  http://www.sparxsystems.com.au/bin/DatabaseModelingInUML.pdf .  

If the definition of a foreign key is not correct then the DDL generated from EA will be missing the foreign key information.

I don't know if any of this information helps, but I hope so.

Paul Mathers

Mark

  • Guest
Re: Data models - associations as foreign keys
« Reply #2 on: December 13, 2001, 03:21:03 pm »
Hi Paul,
thanks for your reply and the data modelling paper. What I'm looking at is modelling compositions using business keys rather than OIDs. Two examples:

1. "Invoice" has one or many "InvoiceItems". In this case I would like "InvoiceItems" to have a primary key of "FK_InvoiceNumber" and "FK_ItemCode".

2. "Customer" owns one many "Accounts" which can be owned by one or many "Customer"s. I would add a seperate table "CustomerAccount" keyed by "FK_CustomerNumber" and "FK_AccountNumber".

Traditional data modelling tools allow me to include the foreign key relationships as part of the primary key.

Cheers,
Mark