Neo4J和其他数据库中唯一ID的最佳实践? [英] Best practice for unique IDs in Neo4J and other databases?

查看:269
本文介绍了Neo4J和其他数据库中唯一ID的最佳实践?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,在运行于Neo4J上的Node.Js应用程序中,我使用node-uuid模块为数据库对象提供唯一的ID.

Currently in my Node.Js app running on Neo4J I use node-uuid module for giving unique IDs to my database objects.

使用该模块的uuid.v1()函数,我得到类似

Using uuid.v1() function from that module I get something like

81a0b3d0-e4d0-11e3-ac56-73f5c88681be

现在,我的请求相当长,有时在一个查询中有数百个节点和边.因此,您可以想象它们变得巨大,因为每个节点和边缘都必须具有唯一的ID.

Now, my requests are quite long, sometimes hundreds of nodes and edges in one query. So you can imagine they become huge, because every node and edge has to have a unique ID.

您知道我是否可以使用较短的ID系统,以便在物品数量增加后不会遇到任何问题?我的意思是我知道我可以只使用前8个符号(因为有36^8 > 2 Trl个组合,但是当它们随机生成时,它的性能如何?随着节点数量的增加,随机出现的几率是多少?生成的ID不会属于已经存在的ID?

Do you know if I could use a shorter ID system in order to not run into any problems after the number of my items grow? I mean I know I could get away with just the first 8 symbols (as there are 36^8 > 2 Trl combinations, but how well will it perform when they are randomly generated? As the number of my nodes increase, what is the chance that the randomly generated ID will not fall into the already existing ones?

另一个问题-如何将当前的ID系统替换为新的ID系统?重新生成较短的新ID的最佳方法是什么?

Another question - how to swap the current ID system to the new one? What would be the best way of regenerating the new, shorter IDs?

谢谢!

推荐答案

一种选择是通过此处开发的非托管扩展将UUID生成移动到数据库端:

One option is to move the UUID generation to the database side via the unmanaged extension developed here: https://github.com/sarmbruster/neo4j-uuid.

此处详细介绍了整个构想:

The whole idea is detailed here: http://blog.armbruster-it.de/2013/08/assigning-uuids-to-neo4j-nodes-and-relationships/.

这篇关于Neo4J和其他数据库中唯一ID的最佳实践?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆