Author Topic: Where are Foreign Keys Stored in the Database?  (Read 1041 times)

fitzsimmons92

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Where are Foreign Keys Stored in the Database?
« on: June 29, 2024, 07:33:49 am »
Hello all.  I have a bunch of table objects that I am relating to each other and defining foreign keys.  I want to run a report that shows me the PK-FK relationship, like custID = customer_id.  Can you help me please?

What I have tried so far:
1. Printing the name the connector. For some reason, that name is blank in t_connector even though the properties show it with a name. 
2. I found in t_attribute, the isOrdered and isConnected field seems to identify the PKs and FKs, but I can't relate that the specific column in the other table.

Is the PK and FK relationship explicitly stored in a table that I have just overlooked?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Where are Foreign Keys Stored in the Database?
« Reply #1 on: June 29, 2024, 10:47:55 pm »
Too long ago, but AFAIR you have to peek into the tagged values (and I can't remember whether is was t_objectproperties or one of the t_xxxtag tables).

q.

Richard Freggi

  • EA User
  • **
  • Posts: 486
  • Karma: +18/-7
    • View Profile
Re: Where are Foreign Keys Stored in the Database?
« Reply #2 on: June 30, 2024, 01:32:47 am »
This is what I use for my queries, seems to work for me

Code: [Select]
CASE WHEN t_attribute.IsOrdered = 1 THEN 'Y' ELSE '' END,--PK
CASE WHEN t_attribute.IsCollection= 1 THEN 'Y' ELSE '' END,--FK
CASE WHEN t_attribute.AllowDuplicates = 1 THEN 'Y' ELSE '' END,-- NN; Weird but correct
CASE WHEN t_attribute.AllowDuplicates = 1 or t_attribute.IsStatic = 1 THEN 'Y' ELSE '' END,--Unique NEED TO ADD OTHER UNIQUE FROM CONSTRAINTS

What FK references what PK is stored in t_connector table and its tags I think
« Last Edit: June 30, 2024, 01:42:28 am by Richard Freggi »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13233
  • Karma: +553/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Where are Foreign Keys Stored in the Database?
« Reply #3 on: July 01, 2024, 07:28:25 pm »
And there is an operation that corresponds to the FK constraint.

Geert