# Two question

**URL:** <https://community.neo4j.com/t/two-question/7748>\
**Category:** Neo4j Graph Platform\
**Created:** [May 30, 2019, 4:39pm UTC](https://community.neo4j.com/t/two-question/7748 "2019-05-30T16:39:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![suleyman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/suleyman/32/3875_2.png) [@suleyman](https://community.neo4j.com/u/suleyman)\
**Post date:** [May 30, 2019, 4:39pm UTC](https://community.neo4j.com/t/two-question/7748/1 "2019-05-30T16:39:45Z")

</div>

for Neo4j enterprise :

1. How to automatic generate id ?
2. How to make general Uniqe constraints ?

---

<div class="post-metadata">

**Author:** ![dominicvivek06](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dominicvivek06/32/5034_2.png) [@dominicvivek06](https://community.neo4j.com/u/dominicvivek06)\
**Post date:** [May 30, 2019, 5:13pm UTC](https://community.neo4j.com/t/two-question/7748/2 "2019-05-30T17:13:41Z")

</div>

1. apoc.create.uuid() or Graphaware UUID ([GitHub - graphaware/neo4j-uuid: GraphAware Runtime Module that assigns a UUID to all nodes (and relationships) in the graph transparently](https://github.com/graphaware/neo4j-uuid))

2.[Constraints - Cypher Manual](https://neo4j.com/docs/cypher-manual/current/schema/constraints/)

---

<div class="post-metadata">

**Author:** ![suleyman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/suleyman/32/3875_2.png) [@suleyman](https://community.neo4j.com/u/suleyman)\
**Post date:** [May 30, 2019, 6:18pm UTC](https://community.neo4j.com/t/two-question/7748/3 "2019-05-30T18:18:29Z")

</div>

thanks you for reply.  
apoc.create.uuid() The string is a guid.  
Does it create problems for performance?  
I must create a unique id number-based?

---

<div class="post-metadata">

**Author:** ![dominicvivek06](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dominicvivek06/32/5034_2.png) [@dominicvivek06](https://community.neo4j.com/u/dominicvivek06)\
**Post date:** [May 30, 2019, 6:39pm UTC](https://community.neo4j.com/t/two-question/7748/4 "2019-05-30T18:39:25Z")

</div>

> [@suleyman](#):
>
> 1. How to automatic generate id ?

do you mean sequence number, as a node property for the data ?

---

<div class="post-metadata">

**Author:** ![suleyman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/suleyman/32/3875_2.png) [@suleyman](https://community.neo4j.com/u/suleyman)\
**Post date:** [May 30, 2019, 7:49pm UTC](https://community.neo4j.com/t/two-question/7748/5 "2019-05-30T19:49:22Z")

</div>

Yes. for node propery id

---

<div class="post-metadata">

**Author:** ![benjamin.squire](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/benjamin.squire/32/1496_2.png) [@benjamin.squire](https://community.neo4j.com/u/benjamin.squire)\
**Post date:** [May 30, 2019, 8:07pm UTC](https://community.neo4j.com/t/two-question/7748/6 "2019-05-30T20:07:13Z")

</div>

If you want to have integer based number that mimics a row\_number for distinct elements you could do something like:

`Match (n:User) with n limit 10 with apoc.coll.zip(range(1,length(collect(n))),collect(n)) as pairs unwind pairs as pair return pair`

Now you could take pair[0] and set it as a property on pair[1]

---

<div class="post-metadata">

**Author:** ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)\
**Post date:** [May 30, 2019, 8:44pm UTC](https://community.neo4j.com/t/two-question/7748/7 "2019-05-30T20:44:58Z")

</div>

In general we would not recommend using a Cypher solution to implement a sequence id, as you'd likely run into race conditions against concurrently running queries. We'd recommend sticking with a UUID instead.

Keep in mind that one huge case for sequence IDs in SQL is as foreign keys between tables to relate entries to each other, and this isn't needed in Neo4j as we use relationships instead, which are not dependent upon these (they are dependent upon the graph ids Neo4j automatically assigns to nodes, but these are not guaranteed to be sequential, as they can be reused after node deletion, and that same characteristic can make them a bad fit for saving outside of Neo4j as a means of node lookup).

---

<div class="post-metadata">

**Author:** ![suleyman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/suleyman/32/3875_2.png) [@suleyman](https://community.neo4j.com/u/suleyman)\
**Post date:** [May 30, 2019, 10:22pm UTC](https://community.neo4j.com/t/two-question/7748/8 "2019-05-30T22:22:04Z")

</div>

thanks you.  
i am trying to learn new
