Comparison between storing data in node and in relation

(Shreyansh Zazz) #1

I am trying to build a team collab app, where One user can join many teams and user's profile may vary between teams (not all attributes but some). I tried building following model for that:

USER :[MEMBER_OF]-> TEAM

USER :[PROFILE_IS]-> PROFILE (Single PROFILE node holding common attributes which will distributed among teams)

MEMBER_OF relations will hold all the properties which will change among different teams such as password, position, email, avatar, etc.

Question is, there could be more than 50 properties which will change. So, is it a good idea to store it in Relation properties and if not then how should I store it?

@michael.hunger

0 Likes

(DKumar) #2

Hi Shrey,
my 2 cents........
An User is a Member of a TEAM through/having a Profile.
That way the profile can save all information like password, position etc, and that profile node can have auth information.

0 Likes

(Shreyansh Zazz) #3

You mean:

USER :[MEMBER_OF]-> TEAM :[HAVING]-> PROFILE

this? @dominicvivek06

0 Likes

(DKumar) #4

USER -[:HAS_PROFILE]->[PROFILE]-[:PART_OF]->[TEAM]

a sample code below.

CREATE CONSTRAINT ON (person:Person) ASSERT person.neogen_id IS UNIQUE;
CREATE CONSTRAINT ON (profile:Pro) ASSERT profile.neogen_id IS UNIQUE;
CREATE CONSTRAINT ON (country:Country) ASSERT country.neogen_id IS UNIQUE;
MERGE (n1:Person {neogen_id: '667faf539ca75a883628513970a947dd60ce0396' })
SET n1.firstname = 'Ashlynn', n1.lastname = 'Reichert';
MERGE (n2:Person {neogen_id: 'acdd1f310c337a0d5708b09924677f82fb42288d' })
SET n2.firstname = 'Kaitlin', n2.lastname = 'Jones';
MERGE (n3:Person {neogen_id: 'a75abb60dcb2745c17c6c2028d465b6e9d5a2e56' })
SET n3.firstname = 'Mikayla', n3.lastname = 'King';
MERGE (n4:Person {neogen_id: '37631174907a1080311bd06d495926a5f9b03d1b' })
SET n4.firstname = 'Josiah', n4.lastname = 'Kessler';
MERGE (n5:Person {neogen_id: '963404c4c92554645d25e38c0bcb715c71516bfa' })
SET n5.firstname = 'Katelyn', n5.lastname = 'Runte';
MERGE (n6:Person {neogen_id: '392af8f0f712280808d711feac9afa6b3a0c5b22' })
SET n6.firstname = 'Elsie', n6.lastname = 'Connelly';
MERGE (n7:Person {neogen_id: '920db2814275f6537472821fd569c81446137853' })
SET n7.firstname = 'Jennifer', n7.lastname = 'Jacobs';
MERGE (n8:Person {neogen_id: '437b4f55d97563e8055f28c7aede9152496b3550' })
SET n8.firstname = 'Juanita', n8.lastname = 'Boyer';
MERGE (n9:Person {neogen_id: '17cf03feb782bad5d454a728bc76c995d2a4a879' })
SET n9.firstname = 'Jensen', n9.lastname = 'Zboncak';
MERGE (n10:Person {neogen_id: '9f5aeac9b90dd2086fe885e7d29a46fde44b5801' })
SET n10.firstname = 'Destini', n10.lastname = 'Oberbrunner';
MERGE (n11:Person {neogen_id: 'f2f4d5ed1ee5a825de5b400e87157b73ef6c88b7' })
SET n11.firstname = 'Santino', n11.lastname = 'Bergstrom';
MERGE (n12:Person {neogen_id: '859d53a6b42cf9c1e81fd6ea9dc8e9c195b0bef1' })
SET n12.firstname = 'Vanessa', n12.lastname = 'Klein';
MERGE (n13:Person {neogen_id: '9b58c5bf3cbf8a50db70e1f04310bf3aa1d0458c' })
SET n13.firstname = 'Armando', n13.lastname = 'Sauer';
MERGE (n14:Person {neogen_id: '83960b181eaed9ccd3f7321c78899e76c5c1056c' })
SET n14.firstname = 'Humberto', n14.lastname = 'Oberbrunner';
MERGE (n15:Person {neogen_id: 'ea384cef572ce7356db27f87cb1e2837f56ba1a5' })
SET n15.firstname = 'Mayra', n15.lastname = 'Kunze';
MERGE (n16:Pro {neogen_id: '954eefefd488bf31f28750fdbb98edf743291dad' })
SET n16.name = 'Borer-Stamm';
MERGE (n17:Pro {neogen_id: 'cef0d5a810acd4b77d40484be05f00c87fea3772' })
SET n17.name = 'Ferry, Senger and Raynor';
MERGE (n18:Pro {neogen_id: '0e0d011a2b876033af97f845e0bc15a9d11f50d7' })
SET n18.name = 'Satterfield, Stracke and Pouros';
MERGE (n19:Pro {neogen_id: 'eacee420511965136140d5e0889f2637cacc0c6c' })
SET n19.name = 'Kuvalis, Walker and Collins';
MERGE (n20:Pro {neogen_id: '5f0df1bbfadd395e9ce7ccfac3a653d5072079f1' })
SET n20.name = 'West-Effertz';
MERGE (n21:Pro {neogen_id: 'bf1c5b5323d45bac3fa2f657aec8874112de5c27' })
SET n21.name = 'Lubowitz LLC';
MERGE (n22:Pro {neogen_id: '648ff36b24add2751714a412fe4b5c913be1c9d3' })
SET n22.name = 'Bogan-Beatty';
MERGE (n23:Pro {neogen_id: '832e22d3a779051f2ccf32495d2e7dace94d7c7d' })
SET n23.name = 'Fadel LLC';
MERGE (n24:Pro {neogen_id: '250e5ecb7d04cdcbc3252a6b3280bcf26dacbb79' })
SET n24.name = 'Sawayn Ltd';
MERGE (n25:Pro {neogen_id: '5e8b901c48a20e8fd79df666237b6b134f95a2b2' })
SET n25.name = 'Lubowitz PLC';
MERGE (n26:Pro {neogen_id: 'cf441290497a9b57b4ea84accc2c31ab1d02df4d' })
SET n26.name = 'Bartell-Ullrich';
MERGE (n27:Pro {neogen_id: '06c55b13e9a3b20b8f29475c44daa4beb51b00fc' })
SET n27.name = 'Murray, Senger and Dicki';
MERGE (n28:Pro {neogen_id: '682328a6307679e63c76d040a11a4edbc795a07a' })
SET n28.name = 'Shields-Hills';
MERGE (n29:Pro {neogen_id: '423e73610fe8c1bebb7afca2f9ffef480884c320' })
SET n29.name = 'Ernser, Walter and Doyle';
MERGE (n30:Pro {neogen_id: 'e4b8f64017984541bc0d366a622a9bd0bfb16556' })
SET n30.name = 'Morar-Nolan';
MERGE (n31:Country {neogen_id: '8594634f32822ba1dcd979a0f7a4fb37f4199e6b' })
SET n31.name = 'Mauritius';
MERGE (n32:Country {neogen_id: 'fa94e95d373471a6a33b4abf26b90d50454bcd0c' })
SET n32.name = 'Bolivia';
MERGE (n33:Country {neogen_id: '1327ddd15f2563e25ffd334b361be4f28c81da05' })
SET n33.name = 'Hong Kong';
MERGE (n34:Country {neogen_id: '99ef9d29d7b055713ded8437bc8b8af83eee4c4d' })
SET n34.name = 'Slovakia (Slovak Republic)';
MERGE (n35:Country {neogen_id: '4cb24ac2d74b68a229ce6d4420da8978009f6557' })
SET n35.name = 'French Southern Territories';
MATCH (s1:Person {neogen_id: '392af8f0f712280808d711feac9afa6b3a0c5b22'}), (e1:Pro { neogen_id: '954eefefd488bf31f28750fdbb98edf743291dad'})
MERGE (s1)-[edge1:HAS_PROFILE]->(e1)
;
MATCH (s2:Person {neogen_id: '83960b181eaed9ccd3f7321c78899e76c5c1056c'}), (e2:Pro { neogen_id: 'cef0d5a810acd4b77d40484be05f00c87fea3772'})
MERGE (s2)-[edge2:HAS_PROFILE]->(e2)
;
MATCH (s3:Person {neogen_id: '667faf539ca75a883628513970a947dd60ce0396'}), (e3:Pro { neogen_id: '0e0d011a2b876033af97f845e0bc15a9d11f50d7'})
MERGE (s3)-[edge3:HAS_PROFILE]->(e3)
;
MATCH (s4:Person {neogen_id: '920db2814275f6537472821fd569c81446137853'}), (e4:Pro { neogen_id: 'eacee420511965136140d5e0889f2637cacc0c6c'})
MERGE (s4)-[edge4:HAS_PROFILE]->(e4)
;
MATCH (s5:Person {neogen_id: '9f5aeac9b90dd2086fe885e7d29a46fde44b5801'}), (e5:Pro { neogen_id: '5f0df1bbfadd395e9ce7ccfac3a653d5072079f1'})
MERGE (s5)-[edge5:HAS_PROFILE]->(e5)
;
MATCH (s6:Person {neogen_id: '859d53a6b42cf9c1e81fd6ea9dc8e9c195b0bef1'}), (e6:Pro { neogen_id: 'bf1c5b5323d45bac3fa2f657aec8874112de5c27'})
MERGE (s6)-[edge6:HAS_PROFILE]->(e6)
;
MATCH (s7:Person {neogen_id: '859d53a6b42cf9c1e81fd6ea9dc8e9c195b0bef1'}), (e7:Pro { neogen_id: '648ff36b24add2751714a412fe4b5c913be1c9d3'})
MERGE (s7)-[edge7:HAS_PROFILE]->(e7)
;
MATCH (s8:Person {neogen_id: 'f2f4d5ed1ee5a825de5b400e87157b73ef6c88b7'}), (e8:Pro { neogen_id: '832e22d3a779051f2ccf32495d2e7dace94d7c7d'})
MERGE (s8)-[edge8:HAS_PROFILE]->(e8)
;
MATCH (s9:Person {neogen_id: 'a75abb60dcb2745c17c6c2028d465b6e9d5a2e56'}), (e9:Pro { neogen_id: '250e5ecb7d04cdcbc3252a6b3280bcf26dacbb79'})
MERGE (s9)-[edge9:HAS_PROFILE]->(e9)
;
MATCH (s10:Person {neogen_id: '9b58c5bf3cbf8a50db70e1f04310bf3aa1d0458c'}), (e10:Pro { neogen_id: '5e8b901c48a20e8fd79df666237b6b134f95a2b2'})
MERGE (s10)-[edge10:HAS_PROFILE]->(e10)
;
MATCH (s11:Person {neogen_id: '667faf539ca75a883628513970a947dd60ce0396'}), (e11:Pro { neogen_id: 'cf441290497a9b57b4ea84accc2c31ab1d02df4d'})
MERGE (s11)-[edge11:HAS_PROFILE]->(e11)
;
MATCH (s12:Person {neogen_id: '667faf539ca75a883628513970a947dd60ce0396'}), (e12:Pro { neogen_id: '06c55b13e9a3b20b8f29475c44daa4beb51b00fc'})
MERGE (s12)-[edge12:HAS_PROFILE]->(e12)
;
MATCH (s13:Person {neogen_id: '920db2814275f6537472821fd569c81446137853'}), (e13:Pro { neogen_id: '682328a6307679e63c76d040a11a4edbc795a07a'})
MERGE (s13)-[edge13:HAS_PROFILE]->(e13)
;
MATCH (s14:Person {neogen_id: '437b4f55d97563e8055f28c7aede9152496b3550'}), (e14:Pro { neogen_id: '423e73610fe8c1bebb7afca2f9ffef480884c320'})
MERGE (s14)-[edge14:HAS_PROFILE]->(e14)
;
MATCH (s15:Person {neogen_id: 'ea384cef572ce7356db27f87cb1e2837f56ba1a5'}), (e15:Pro { neogen_id: 'e4b8f64017984541bc0d366a622a9bd0bfb16556'})
MERGE (s15)-[edge15:HAS_PROFILE]->(e15)
;
MATCH (s16:Pro {neogen_id: '954eefefd488bf31f28750fdbb98edf743291dad'}), (e16:Country { neogen_id: 'fa94e95d373471a6a33b4abf26b90d50454bcd0c'})
MERGE (s16)-[edge16:IN_TEAM]->(e16)
;
MATCH (s17:Pro {neogen_id: 'cef0d5a810acd4b77d40484be05f00c87fea3772'}), (e17:Country { neogen_id: 'fa94e95d373471a6a33b4abf26b90d50454bcd0c'})
MERGE (s17)-[edge17:IN_TEAM]->(e17)
;
MATCH (s18:Pro {neogen_id: '0e0d011a2b876033af97f845e0bc15a9d11f50d7'}), (e18:Country { neogen_id: 'fa94e95d373471a6a33b4abf26b90d50454bcd0c'})
MERGE (s18)-[edge18:IN_TEAM]->(e18)
;
MATCH (s19:Pro {neogen_id: 'eacee420511965136140d5e0889f2637cacc0c6c'}), (e19:Country { neogen_id: '99ef9d29d7b055713ded8437bc8b8af83eee4c4d'})
MERGE (s19)-[edge19:IN_TEAM]->(e19)
;
MATCH (s20:Pro {neogen_id: '5f0df1bbfadd395e9ce7ccfac3a653d5072079f1'}), (e20:Country { neogen_id: '99ef9d29d7b055713ded8437bc8b8af83eee4c4d'})
MERGE (s20)-[edge20:IN_TEAM]->(e20)
;
MATCH (s21:Pro {neogen_id: 'bf1c5b5323d45bac3fa2f657aec8874112de5c27'}), (e21:Country { neogen_id: '4cb24ac2d74b68a229ce6d4420da8978009f6557'})
MERGE (s21)-[edge21:IN_TEAM]->(e21)
;
MATCH (s22:Pro {neogen_id: '648ff36b24add2751714a412fe4b5c913be1c9d3'}), (e22:Country { neogen_id: '4cb24ac2d74b68a229ce6d4420da8978009f6557'})
MERGE (s22)-[edge22:IN_TEAM]->(e22)
;
MATCH (s23:Pro {neogen_id: '832e22d3a779051f2ccf32495d2e7dace94d7c7d'}), (e23:Country { neogen_id: '4cb24ac2d74b68a229ce6d4420da8978009f6557'})
MERGE (s23)-[edge23:IN_TEAM]->(e23)
;
MATCH (s24:Pro {neogen_id: '250e5ecb7d04cdcbc3252a6b3280bcf26dacbb79'}), (e24:Country { neogen_id: '99ef9d29d7b055713ded8437bc8b8af83eee4c4d'})
MERGE (s24)-[edge24:IN_TEAM]->(e24)
;
MATCH (s25:Pro {neogen_id: '5e8b901c48a20e8fd79df666237b6b134f95a2b2'}), (e25:Country { neogen_id: '4cb24ac2d74b68a229ce6d4420da8978009f6557'})
MERGE (s25)-[edge25:IN_TEAM]->(e25)
;
MATCH (s26:Pro {neogen_id: 'cf441290497a9b57b4ea84accc2c31ab1d02df4d'}), (e26:Country { neogen_id: '99ef9d29d7b055713ded8437bc8b8af83eee4c4d'})
MERGE (s26)-[edge26:IN_TEAM]->(e26)
;
MATCH (s27:Pro {neogen_id: '06c55b13e9a3b20b8f29475c44daa4beb51b00fc'}), (e27:Country { neogen_id: '8594634f32822ba1dcd979a0f7a4fb37f4199e6b'})
MERGE (s27)-[edge27:IN_TEAM]->(e27)
;
MATCH (s28:Pro {neogen_id: '682328a6307679e63c76d040a11a4edbc795a07a'}), (e28:Country { neogen_id: 'fa94e95d373471a6a33b4abf26b90d50454bcd0c'})
MERGE (s28)-[edge28:IN_TEAM]->(e28)
;
MATCH (s29:Pro {neogen_id: '423e73610fe8c1bebb7afca2f9ffef480884c320'}), (e29:Country { neogen_id: '1327ddd15f2563e25ffd334b361be4f28c81da05'})
MERGE (s29)-[edge29:IN_TEAM]->(e29)
;
MATCH (s30:Pro {neogen_id: 'e4b8f64017984541bc0d366a622a9bd0bfb16556'}), (e30:Country { neogen_id: '4cb24ac2d74b68a229ce6d4420da8978009f6557'})
MERGE (s30)-[edge30:IN_TEAM]->(e30)
;
MATCH (n1:Person) REMOVE n1.neogen_id;
MATCH (n2:Pro) REMOVE n2.neogen_id;
MATCH (n3:Country) REMOVE n3.neogen_id;

1 Like

(Shreyansh Zazz) #5

@dominicvivek06 How would I query for all members that are in a particular team? This solution seems better than mine but it's so indirect. The relation between a User and Team should be direct, no?

0 Likes

(DKumar) #6

@shrey.binary -- here is a snippet. What is all your query pattern ?

match (c:Country)<-[*1..2]-(p:Person)
return c.name,p.firstname
ORDER by c.name,p.firstname

You can include a WHERE clause in the above statement for country.
This is just a sample data and code(query), for your requirement.

0 Likes

(Shreyansh Zazz) #7

I am thinking of implementing this solution like following in my case:

USER -[:HAS_PROFILE]-> PROFILE (for common attributes)

USER -[:HAS_TEAM_PROFILE]-> TEAM_PROFILE -[:PART_OF]-> TEAM (for different attributes)

Following are the queries I will be needing:

  • Fetch all members in a team
  • Fetch all teams a member is a part of
  • Login the user based on team i.e. user have to enter the team first in which he/she wants to login then the email and password

@dominicvivek06

Apart from profile there are tons of other settings too that will vary in different teams, like settings, notification settings, messages, files/attachments, replies etc.

0 Likes