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

Feature Request: Allow automatic creation of relationship on duplicate during create/update #463

Open
ravensorb opened this issue May 29, 2016 · 0 comments

Comments

@ravensorb
Copy link
Contributor

One of the great things about a graph database is the ability to leverage relationships between existing entities to both describe a larger concept and at the same time reduce the amount of duplication of data. It would be a great feature if structr had an option to automatically associate entities during create/update operations based on a unique constraint violation.

Consider the following (Note: Address has a unique constraint on Line1, City, State, and Postal Code)

  • Create: User U1 is located at Address A1 and Works at A2
  • Create: User U2 is located at Address A3 and Works at A2
  • Update: User U1 is now located at Address A3 and now Works at A5

When I create U1, I would expect A1 and A2 to automatically be created -- this is possible today using the "Automatic Creation of Related Nodes" option.

When I create U2, I would expect A3 to be automatically created and a relationship between U2 and A2 to be created -- this does NOT seem to be possible today (unless I am missing something)

When I update U1, I would expect a relationship be created to Address A3 and a new address created for A5 -- note, I would expect I need to manually remove the relationship to Address A1.

While I know ALL of this is manually possible by creating the individual records and manually creating the relationships it requires a very large number of queries to be executed.

Consider what currently needs to be done

For Create

  • Query for U1, if not found Create User U1 (2 API calls)
  • Query for A1, if not found Create Address A1 (2 API calls)
  • Query for relationship between U1 and A1, if not found create relationship (2 API calls)

For Update

  • Query for U1, if found Update User U1 (2 API calls)
  • Query for A1, if found Update Address A1, if not found create Address A1 (3 API calls)
  • Query for relationship between U1 and A1, if not found create relationship (2 API calls)

For just one instance you have at best 3 API calls and at worst 7 API calls. Where as the idea I am suggestion would amount to at most 2 API calls (Query for User, Create/Update with related records) and structr would internally take care of Creating/Updating related records.

Thoughts?

@amorgner amorgner changed the title Feature Request: Allow automatic creatation of relationship on duplicate during create/update Feature Request: Allow automatic creation of relationship on duplicate during create/update Sep 29, 2016
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

1 participant