Java - Google App Engine - modeling county structures in a Google data warehouse

The Google Apps Engine offers the Google data warehouse as the only NoSQL database (I think it is based on BigTable).

In my application, I have a structure similar to a social structure, and I want to model it the way I would do in the graph database. My application should save heterogeneous objects (users, files, ...) and the relationships between them (e.g. user1 OWNS file2, user2 FOLLOWS user3, etc.).

I am looking for a good way to simulate this typical situation, and I thought of two families of solutions:

  • List Based Solutions. Any object contains a list of other related objects, and the presence of an object in the list itself is a relation (as Google said in the JDO part https://developers.google.com/appengine/docs/java/datastore/jdo/relationships ).

  • Graphical solution: both nodes and relationships are objects. Objects exist independently of a relationship, while each relationship contains a link to two (or more) related objects.

What are the strengths and weaknesses of these two approaches?

About approach 1: This is a simpler approach that you can think of, and it is also presented in the official documentation, but:

  • Each directional relation increases the indicator of the object: are there any restrictions on the number of possible relations given, for example, by the measurement limit of the object?
  • JDO, ?
  • , () ?

2: ( , ). , Google, :

  • , . (, )? Google , ? , User1 User4. ?
  • , .

, ?

+4
3

-, , . , , , .

-, , " ". , , . - , , - google, .

-, . , , . , . , , .

UPDATE:

, . Relationship , , , . , , .

+5

AppEngine, . : , .

1: Objectify . .

2: 'id' 'DataStore' . , .

, , , . . "". , UserSchoolLinks /, , . , id = '6h30n' UserSchoolLinks '6h30n'. , .

, . . . . , SchoolUserLink "6h30n", "g3g0a3", "g3g0a3 ~ 6h30n" : school = g3g0a3 user = 6h30n. , SchoolUserLinks .

:

  • , . , , .

  • , . .

  • , . , .

  • , , . , .

  • User UserSchoolLinks, , .

  • SchoolUser. , , . , .

  • SchoolUserLink, SchoolUserLink, . , - .

Downsides:  1. . .  2. , , . .

UserSchoolLinks / SchoolUserLink .

+1

, ( Python, Java).

class User(db.User):
  followers = db.StringListProperty()

.

user = User.get(key)
user.followers.append(str(followerKey))

User.all().filter('followers', followerKey) # -> followed

i/o , , -:

class User(db.User):
  followers = db.StringListProperty()
  follows = db.StringListProperty()

, , 2 .

, , , , ... - , 1Mb, , .

-1
source

Source: https://habr.com/ru/post/1536603/


All Articles