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.

Creating a single relationship between multiple type of nodes

Hi all
I am trying to design my own project and was curious about something once I finished design. So initially My system had the follwoing two relationships going on

(User) -[LIVES_AT]->(Address)-[HASZIP]->Zipcode
(Clubs) -[LOCATED_AT]->(Address)-[HASZIP]->Zipcode

After the first iteration I figured I should remove the address node entirely(it had no properties in it that I really wanted to keep). So now I want it something like

(User) -[HASZIP]->Zipcode
(Clubs) -[HASZIP]->Zipcode

So here is the question part. When writing a typedef for this realtionship, I want the api to allow user to be null or club to be null but not both. Is there a way to achieve this?

type HAS_ZIP @relation(name: "HAS_ZIP"){

id:ID!

user: User(not sure?)

club: Club(not sure?)

zipcode : ZIPCode!

}

1 ACCEPTED SOLUTION

jggomez
Graph Voyager

Hi, I don't know abou typedef but you could use the constraints o created a query that get both relations a compare if is null.

Thanks

View solution in original post

3 REPLIES 3

jggomez
Graph Voyager

Hi, I don't know abou typedef but you could use the constraints o created a query that get both relations a compare if is null.

Thanks

Oh ye that makes sense. Do you guys have any sample projects that make use of contraints ?
Thanks again for the help

Hi
You can see info about constrainsts here:

Thanks