cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Should I use different ID names when creating constraints for uniqueness?

lingvisa
Graph Fellow

Let's say I want to have a unique ID for each node, Student and Teacher, two labels. In creating the ID columns, can I use 'ID' for both Student and Teacher nodes, or I should use "Student_ID" and "Teacher_ID" for the two different types? I need to create constraints on each node by the ID.

1 REPLY 1

It shouldn't be a problem to call the property ID on both node types, since you define a constraint against a specific label:

CREATE CONSTRAINT constraint_name
ON (book:Book) ASSERT book.isbn IS UNIQUE

Just make sure that when using the index that gets created with the constraint, you specify the same label, otherwise it won't work. For example if both :Student and :Teacher nodes were also :Person nodes, you wouldn't have access to the index when matching :Person