Hello all,

I'm writing a dating application (similar to tinder) for which I'm using 
OrientDB to manage the relationships. I'm doing this by making users login 
through facebook and get a list of their friends. I store these list of 
friends on OrientDB in the graph format. The application is supposed to 
suggest some possible matches from their 4th level connections.

I have done this using play framework and connect to the graph db via the 
jar files.

Following are the commands I used:

1) To depict users of an application

create class Person extends V 

2) To depict relationships:

create class Friend extends E
create class Like extends E
create class Dislike extends E
create class Match extends E
create class Block extends E

Where:
- Friend edges are created at the time they sign up with the list of 
friends from facebook
- Like edges are created when they "like" someone
- Dislike edges are created when they "dislike" someone
- Match edges are created when they are "matched" with someone.
- Block edges are created when they "block" someone

I have already managed to write the application logic for adding friends, 
adding friend edges, like and dislike edges. But I'm struggling with is the 
SQL required to get their 4th level of connections and make suggestions 
following some rules like:

1) They should not see someone that they have already seen (like, dislike 
or match)
2) They should not see blocked people

Now my question is:

1) How do I write sql so that I get people from their 4th level of 
connections?
2) How to write the sql so that it's optimized despite so many rules like 
above, which I plan to implement by adding an edge between the person 
vertex in question and the other person vertex - is it the most optimized 
way to do it?

Adding some info below:

orientdb {db=friend}> select from Person limit 50

----+------+-------------------+----------+---------
#   |@RID  |facebookId         |out_Friend|in_Friend
----+------+-------------------+----------+---------
0   |#11:36|12312312312312     |[size=3]  |[size=3]
1   |#11:37|1231232131231231232|[size=2]  |[size=2]
2   |#11:38|123123213          |#11:36    |#11:36
3   |#11:39|12312312132        |#11:36    |#11:36
4   |#11:40|12                 |[size=7]  |[size=7]
5   |#11:41|1                  |#11:40    |#11:40
6   |#11:42|2                  |[size=2]  |[size=2]
7   |#11:43|3                  |#11:40    |#11:40
8   |#11:44|4                  |#11:40    |#11:40
9   |#11:45|5                  |#11:40    |#11:40
10  |#11:46|13                 |[size=8]  |[size=8]
11  |#11:47|6                  |#11:46    |#11:46
12  |#11:48|7                  |#11:46    |#11:46
13  |#11:49|8                  |#11:46    |#11:46
14  |#11:50|9                  |#11:46    |#11:46
15  |#11:51|10                 |#11:46    |#11:46
16  |#11:52|14                 |[size=7]  |[size=7]
17  |#11:53|11                 |#11:52    |#11:52
18  |#11:54|15                 |#11:52    |#11:52
19  |#11:55|16                 |#11:52    |#11:52
20  |#11:56|17                 |#11:52    |#11:52
21  |#11:57|18                 |#11:52    |#11:52
22  |#11:58|19                 |#11:52    |#11:52
----+------+-------------------+----------+---------

23 item(s) found. Query executed in 0.062 sec(s).

orientdb {db=friend}> classes;


CLASSES
----------------------------------------------+------------------------------------+------------+----------------+
 NAME                                         | SUPERCLASS                 
        | CLUSTERS   | RECORDS        |
----------------------------------------------+------------------------------------+------------+----------------+
 _studio_bookmark                             |                             
       | 13         |              0 |
 Dislike                                      | E                           
       | 15         |              0 |
 E                                            |                             
       | 10         |              0 |
 Friend                                       | E                           
       | 12         |              0 |
 Like                                         | E                           
       | 14         |              0 |
 Match                                        | E                           
       | 16         |              0 |
 OFunction                                    |                             
       | 7          |              0 |
 OIdentity                                    |                             
       | -          |              0 |
 ORestricted                                  |                             
       | -          |              0 |
 ORIDs                                        |                             
       | 6          |              0 |
 ORole                                        | OIdentity                   
       | 4          |              3 |
 OSchedule                                    |                             
       | 8          |              0 |
 OTriggered                                   |                             
       | -          |              0 |
 OUser                                        | OIdentity                   
       | 5          |              4 |
 Person                                       | V                           
       | 11         |             23 |
 V                                            |                             
       | 9          |             12 |
----------------------------------------------+------------------------------------+------------+----------------+
 TOTAL = 16                                                                 
                                  42 |
----------------------------------------------+------------------------------------+------------+----------------+


Happy to add more info. Please help :)







-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to