Guidance on schema (ordered list of edges)

HI,

I am pretty new to DGraph and graph database in general so I may be overthinking my problem… or not.
From the tutorial material I can not seem to find how to schematize an “ordered list of edges”.

Eg. A chat conversation using only emoticons. This is what I have:

alter

user_id: string @index(term) .
chat_id: string @index(term) .
emoticon_id: string @index(term) .

author_0: uid .
author_1: uid .

msg_0: uid .
msg_1: uid .
msg_2: uid .
msg_3: uid .

mutate

{
  set {
    _:user0 <user_id> "alice" .
    _:user1 <user_id> "bob" .

    _:chat0 <chat_id> "good moring!" .

    _:emo0 <emoticon_id> ":smile:" .
    _:emo1 <emoticon_id> ":sad:" .
    _:emo2 <emoticon_id> ":mad:" .
    _:emo3 <emoticon_id> ":cool:" .
    
    _:user0 <author_0> _:chat0 .
    _:user1 <author_1> _:chat0 .
    
    _:chat0 <msg_0> _:emo2 .
    _:chat0 <msg_1> _:emo3 .
    _:chat0 <msg_2> _:emo0 .
    _:chat0 <msg_3> _:emo1 .
  }
}
  1. Can I get rid of author_0 and author_1 and keep the order, eg. to map the proper author with msg_x (let assume the business logic enforces alternate posting of messages)? Same thing for msg_0, …, msg_x.

It may be trivial but I don’t see it.

Thx!

Listening at 11:30 in:

A distributed graph database written in Go - GopherCon SG 2017

I think I just need to add timestamps and I should be good to preserve order.

I think your approach is a little wrong. You will create multiple predicates. that way pollutes your scheme completely. Imagine the moment you are pulling your schema. It will come thousands of predicates.

The best thing to do is to create specific Nodes for each emoji (Or even in the application use a pattern already produced from third parties. Nor would you need to create ““physical nodes”” in DB Dgraph). Then connect them Via UID. In that case your application would have to deal with this UID translation for emoticon. in this case you would have a predicate called Body, which would be the body of the message. And your application would translate specific body points from that message as emoticon.

See this example below. It’s old, but I think it’a aligned with todays parameters. And I still have to finish and remodel some things there. It was a sketch I created to set up a chat. https://realtimeboard.com/app/board/o9J_k0N22Eo=/

Will check that with great care. Thanks.