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

When a table has several FK all constraints to a first table are skipped #3

Open
s13o opened this issue Dec 3, 2020 · 3 comments
Open

Comments

@s13o
Copy link
Contributor

s13o commented Dec 3, 2020

When we have DDL like this

CREATE TABLE PATIENT (
  MASTER_PATIENT_IDENTIFIER STRING(MAX) NOT NULL,
  DATE_OF_BIRTH TIMESTAMP,
  FIRST_NAME STRING(MAX),
  LAST_NAME STRING(MAX),
  MIDDLE_NAME STRING(MAX),
  GENDER STRING(MAX),
) PRIMARY KEY(MASTER_PATIENT_IDENTIFIER);

CREATE TABLE FACILITY (
  FACILITY_NUMBER STRING(MAX) NOT NULL,
  FACILITY_NAME STRING(MAX),
  PRIMARY_PHONE STRING(MAX),
) PRIMARY KEY(FACILITY_NUMBER);

CREATE TABLE CARE_ACTIVITY (
  PATIENT_CARE_ACTIVITY_ID STRING(MAX) NOT NULL,
  MASTER_PATIENT_IDENTIFIER STRING(MAX) NOT NULL,
  FACILITY_NUMBER_CREATED_AT STRING(MAX),
  FACILITY_NUMBER_COMPLETED_AT STRING(MAX),
  CONSTRAINT FK_1 FOREIGN KEY(MASTER_PATIENT_IDENTIFIER) REFERENCES PATIENT(MASTER_PATIENT_IDENTIFIER),
  CONSTRAINT FK_2 FOREIGN KEY(FACILITY_NUMBER_CREATED_AT) REFERENCES FACILITY(FACILITY_NUMBER),
) PRIMARY KEY(MASTER_PATIENT_IDENTIFIER, PATIENT_CARE_ACTIVITY_ID);

the constraint FK_1 will be skipped.
If you will switch positions of the TABLE PATIENT and TABLE FACILITY in this DDL the FK_2 will be skipped.

@s13o s13o changed the title When a table has several FK all constraints to a first table is skipped When a table has several FK all constraints to a first table are skipped Dec 3, 2020
@nktks
Copy link
Owner

nktks commented Dec 9, 2020

spanner-er make node and subgraph for defining group internaly.
If group not exists, graph will be horizontaly long when 1:n(many) interleave relation exists.
And graphviz does not draw edge between another subgraph...

So I'll implement FK as attribute at table node, not as edge.

@s13o
Copy link
Contributor Author

s13o commented Dec 9, 2020

So, do you believe we should have only one FK-arrow on a diagram from the example above? Because I was unable to generate a diagram with both arrows rendered at the same time.
I just don't really sure I understood your explanation well, sorry.

@nktks
Copy link
Owner

nktks commented Dec 10, 2020

So, do you believe we should have only one FK-arrow on a diagram from the example above?

Offcource not.
It's kind of bug of spanner-er.
But I can't fix it quickly, I just wrote the reason why I can't fix quickly.

Sorry for my bad English...

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