Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship between Unique Keys and Foreign Key #1430

Open
KhemrajShankarappa opened this issue Apr 1, 2024 · 8 comments
Open

Relationship between Unique Keys and Foreign Key #1430

KhemrajShankarappa opened this issue Apr 1, 2024 · 8 comments

Comments

@KhemrajShankarappa
Copy link

Expected Behavior

Oracle allows to build child-parent relation between Unique-Key and FK.
SchemaSpy is working fine for the relationships defined between Primary Key and Foreign Key.
In our organization we have defined some relations between Unique Keys and Foreign Key. (where unique key column is parent and other one being child)

Current Behavior

SchemaSpy reconize relations only between PK and FK, not UK and FK

Possible Solution

Is there any way I can make SchemaSpy to consider such constraints as well and show lines in relationship tab?

Steps to Reproduce (for bugs)

Context

  • Database type (e.g. MySQL): Oracle
  • Database driver version (is you use a special one):
  • Your DDL (sample how to reproduce the issue):
  • Full command including arguments how you run SchemaSpy:

Your Environment

  • Version used:
  • Environment name and version (e.g. Chrome 39):
  • Operating System and version (e.g. Windows 10):
  • Java version:
@KhemrajShankarappa
Copy link
Author

Can someone pls help

@npetzall
Copy link
Member

npetzall commented Apr 3, 2024

Could you supply a small example with just two tables and how the relationship is declared.

Implied won't find it I think, it only looks at PK.

But we do ask the jdbc driver for imported and exported columns/keys.

For me to look into this I also need to know the version of Oracle and driver so that I'm sure to reproduce the issue.

Then I can check different driver if they allow this else we might consider expanding the implied to check on both PK and UQ indexes.

@KhemrajShankarappa
Copy link
Author

Please see attached screenshot, Attendance_time table has FK to Attendance table (referring to UK for that table)

image

In schema spy this is not visible, hence its not showing up in relationships diagram . We are using ojdbc8-19.14.0.0 driver
Is there any fix for this? so that my FK on UK also visible

image

@KhemrajShankarappa
Copy link
Author

Version of Oracle is 19.14

@npetzall
Copy link
Member

npetzall commented Apr 3, 2024

Would you be able to supply Sql statement to produce this kind of relationship.

I'm gonna check if there is any filtering applied if a FK is returned but it doesn't reference a PK. Because

@KhemrajShankarappa
Copy link
Author

Please use this test case:

CREATE TABLE SUPPLIER_KHEM
( supplier_id numeric(10) not null,
supplier_name varchar2(50) not null,
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
);

CREATE TABLE PRODUCTS_KHEM
( product_id numeric(10) not null,
supplier_id numeric(10) not null,
CONSTRAINT fk_supplier
FOREIGN KEY (supplier_id)
REFERENCES supplier_khem(supplier_id),
CONSTRAINT products_unique UNIQUE (product_id)
);

CREATE TABLE ORDERS_KHEM
( order_id numeric(10) not null,
prodids numeric(10) not null,
CONSTRAINT fk_orders
FOREIGN KEY (prodids)
REFERENCES products_khem(product_id)
);

You will see relation between supplier and products but Orders table is not in picture.
image

@npetzall
Copy link
Member

npetzall commented Apr 6, 2024

I'll need some additional time to look into this, since I find the Oracle 19 container images for M1 a little sketchy since I can't find a release to download of the software for M1(arm64). I'll need to have time to sitt at a different computer.

@KhemrajShankarappa
Copy link
Author

KhemrajShankarappa commented Apr 9, 2024

Sure, meanwhile i tried -meta option as a workaround. Its working but we cant use this method.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants