I’m coming from PHP/SQL, so I’m used to statements such as:
SELECT name FROM authors WHERE alive = true;
Is there something like this available on this system? I know that a “variable start” is needed in the form of:
(xid: Isaac Asimov) { alive }
So how would I get all authors that have alive set to true?
If the answer is to set the xid to “alive”, how would I add that as an external id? Is that even possible?
So something like:
(xid: alive) { name }
Would I then have to have all of my mutations use the subject of “alive” rather than “name”? Or can I somehow add “alive” as an index (again, coming from SQL, so not sure of the proper naming conventions).
EDIT:
I believe I was thinking about this in the wrong way. If I write:
mutation {set { “Alice” }}
then is the XID. So I guess my question is: how do I work with “tables” in Dgraph? I think they’re called “nodes”.
For example, if I had a relational database with the tables “users” and “tickets” and wanted to add a user and some tickets and relate the tickets to a user I would use a third table that uses unique IDs (aptly named “id”).
For a graph database it seems like I would need to set that ID manually somehow without doing a lookup of many users to see if it was already being used- fair enough for a small data set; perhaps a full name would suffice, but how would you check that against a very large database to be sure that name wasn’t already in use? I think this is where UIDs come in to play, but I’m not sure how to get that return information so I can then use it, or if I even have to. I think it’s pretty clear that I’m fumbling around in the dark.
I think Dgraph is unique enough to where these things need to be addressed for us lowly web developers that have only used relational databases in the past. Scouring the internet for resources and trying to apply the theory in Dgraph has left me almost exactly where I started, except now I have more questions.
How would you translate related tables to the graph way of doing things?
Update: Here’s a starting point that will help people understand graph:
http://www.linkeddatatools.com/introducing-rdf