Table AUFK has a column called ADRNRA.
The values in column ADRNRA have matching rows in table ADRC.
In this case I found ADRC because someone told me the solution.
Maybe I am blind, but it looks like AUFK-ADRNRA is no explicit foreign key.
Is there a way to do introspection and find the matching related table (in this example ADRC) with a script or with SQL?
What Does Foreign Key Mean? A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It acts as a cross-reference between tables because it references the primary key of another table, thereby establishing a link between them.
A foreign key allows you to assign data records in the foreign key table and check table. By using the entries in the foreign key fields, one record of the foreign key table uniquely identifies one record of the check table. Check Field and Value Check. One of the foreign key fields is marked as the check field.
Indeed the field is not marked as foreign key of the field ADDRNUMBER
of the table ADRC
but should you have looked at the domain of the field ADRNRA
of the table AUFK
you would have found the reference in just a few seconds.
The domain (in this case AD_ADDRNUM
) has an explicitly specified value table which is, surprise, surprise, ADRC
.
Nope, there is no easy way to reveal foreign keys in an SAP system. :-(
Database management systems don't require you to model foreign keys. You only do that when you want to enforce constraints such as "must refer to a row in the other table" and automatic reactions such as cascading deletion ("delete this row if its 'parent' row in the other table is deleted").
Older SAP applications implemented constraints and reactions like these in the application layer, i.e. the ABAP code. They didn't have a need for modeled relations, and thus people simply didn't model them.
Common means to identify foreign key relationships are:
There are also some experimental machine learning algorithms that try to detect relations; google "foreign key discovery" for more information.
As @Sandra points out in her comment, newer SAP applications reveal a lot more relationships because they use CDS views. Modeling relationships there has direct benefits such as automatically generating associations in OData services, selecting along relations, and using them to model business objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With