Book a Demo

Author Topic: implicit primary key?  (Read 5715 times)

eberline

  • EA User
  • **
  • Posts: 40
  • Karma: +1/-0
    • View Profile
implicit primary key?
« on: November 02, 2006, 05:38:15 pm »
Any thoughts on the best way to model a database table in which the primary key is implicit, for example a table record POID? Specifically, in an EDB volume on Windows Mobile, I want to use the CEOID value returned by CeWriteRecordProps and CeReadRecordPropsEx as the primary key. Sort of like a derived attribute, that is, not an explicit table column, but I don't see how to model such in a classifier stereotyped «table».

And of course I want to be able to use it in a foreign key constraint elsewhere.

Any ideas?

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: implicit primary key?
« Reply #1 on: November 02, 2006, 05:51:39 pm »
Hi,

I think you are describing what is more commonly called a Surrogate Key:

"Sometimes, it is useful to allocate a special column to use as the primary key of a table.  We can enforce a high degree of stability by ensuring that no external (or domain) column is used as any part of the key.  The special column “takes the place of” the other columns that would normally constitute a candidate key in the external domain.  In other words, this key is a surrogate for the external candidate, hence: surrogate key."

I would model the column, make it a PK and then add the additional stereotype (which you can now do with 6.5) of «surrogate».

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

eberline

  • EA User
  • **
  • Posts: 40
  • Karma: +1/-0
    • View Profile
Re: implicit primary key?
« Reply #2 on: November 02, 2006, 06:21:00 pm »
Thank you, that's exactly the concept I needed.

Quote
add the additional stereotype (which you can now do with 6.5)


Curiously, EA 6.5.799 supports multiple stereotypes for class attributes but not «table» columns. I've now mentioned that in the suggestions forum.

eberline

  • EA User
  • **
  • Posts: 40
  • Karma: +1/-0
    • View Profile
Re: implicit primary key?
« Reply #3 on: November 02, 2006, 06:37:14 pm »
... Although in this case that's ok, because what I want to model isn't a column at all, at least from a perspective outside the database engine internals. So the single stereotype of «surrogate» is fine.