Giter Club home page Giter Club logo

Comments (5)

endlesskwazar avatar endlesskwazar commented on May 24, 2024 1

Thank you, for detailed response and explanation. It helped me a lot.

from laravel-arangodb.

LaravelFreelancerNL avatar LaravelFreelancerNL commented on May 24, 2024 1

I've just released 0.14 to make it easy to upgrade to it. It's the version with _key/id conversion. So it should be easy to upgrade to it from any version below 0.10 and skip the _id primaryKey from versions 0.10 - 0.13.

from laravel-arangodb.

endlesskwazar avatar endlesskwazar commented on May 24, 2024 1

Wow, thank you so much, there are so many cool features in releases in/above 0.10, so excited :)

from laravel-arangodb.

LaravelFreelancerNL avatar LaravelFreelancerNL commented on May 24, 2024

Hi, you're welcome.

id/_key vs _id

Back in the day I thought that _id would map nicely to 'id'; which was indeed easy and at first usage worked out nicely.
However it caused several follow up problems. A lot of third-party packages just assume an 'id' field and default to it or even hard code that in relationships and database queries.

So the mapping started to break down. To further compound on this issue it also required to override the default route key as
it's structure ({collection}/{_key}) isn't compatible with URL usage.

I've solved these problems in dev-next by mapping _key to 'id' on data retrieval and 'id' to _key in statement queries.
This is the most compatible solution I could come up with and since then most third-party packages can be used out of the box.

The most common incompatibilities are now the need to register locations in transactions and the lack of foreign keys in Arangodb, so you need to handle cascading deletes manually.

The model's primary key is now the regular 'id'. The only real problem with this is naming confusion when learning ArangoDB through this package, or coming from ArangoDB usage elsewhere. As _id and id are usually pronounced the same.

So, for regular eloquent usage I suggest to just default 'id' for relationships and queries.

You can use _id in relationships by setting them manually. So that allows you to use graphs and maintain eloquent functionality.
Note to set the collection type of the pivot to edge.

So this will be released in 1.0; until then you can check out dev-next; but of course the risk of breaking changes remains until 1.0 is released.


Performance

Both _key and _id are indexed by ArangoDB automatically. The difference is very minimal so you'll probably won't notice it in most use cases. I've just tried to find this information again but couldn't locate it. As I recall it's mentioned somewhere in the docs or one of the learner pdf's on their website.

For general usage I'd go for _key in regular joins and _id for graphs, polymorphic relationships (outside of eloquent) etc.
Basically use what makes sense from a data modelling perspective.

For third-party packages the first part of this reply already takes care of that by using _key under the hood..

Either way I wouldn't worry about it unless you go to the extreme use cases. ArangoDB is very fast.
If, in practice, you really do need every last drop of performance you can easily swap between _key and _id as the _key is part of the _id anyway. But doing that beforehand just for the sake of performance might just be a premature optimization.

If you have an extreme use-case you can run some performance tests on a large dataset under load.


Does this alleviate your concerns?

from laravel-arangodb.

LaravelFreelancerNL avatar LaravelFreelancerNL commented on May 24, 2024

Good luck over there! I hope you and your loved ones are and stay well!

from laravel-arangodb.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.