# Please support uid type for facet edge attributes

**URL:** <https://discuss.dgraph.io/t/please-support-uid-type-for-facet-edge-attributes/8481>\
**Category:** Dgraph\
**Tags:** dgraph, kind:enhancement, status:accepted, area:facets\
**Created:** [February 13, 2020, 4:20pm UTC](https://discuss.dgraph.io/t/please-support-uid-type-for-facet-edge-attributes/8481 "2020-02-13T16:20:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [February 13, 2020, 4:20pm UTC](https://discuss.dgraph.io/t/please-support-uid-type-for-facet-edge-attributes/8481/1 "2020-02-13T16:20:53Z")

</div>

**Moved from GitHub [dgraph/4770](https://github.com/dgraph-io/dgraph/issues/4770)**

_Posted by_ [ChStark](https://github.com/ChStark):

### What you wanted to do

Modeling some entities as edges

Sometimes when modeling a domain on a graph database makes more sense that some entities are modeled as edges and not nodes, lets say the typical case of airports and flights, flights make more sense like edges since is connecting 2 node entities (airports) and the information they need is primitive like start times and end times, etc

Then if there is a need to include some extra information or pointers to another nodes, let’s say pilots, a whole refactor/export is needed.

### What you actually did

Create a new type of node and refactor/export all the information just because I need to point one single attribute to a node

### Why that wasn’t great, with examples

Its suppose that graph database should be flexible for schema evolution and changes, but this is not the case.

### Any external references to support your case

If you go to ArangoDb’s docs you can see the make a clear distinction of this concept  
[https://www.arangodb.com/docs/stable/graphs.html#which-part-of-my-data-is-an-edge-and-which-a-vertex](https://www.arangodb.com/docs/stable/graphs.html#which-part-of-my-data-is-an-edge-and-which-a-vertex)  
And if you have the above distinction you can’t change easily between edges → nodes.

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [December 23, 2020, 6:28pm UTC](https://discuss.dgraph.io/t/please-support-uid-type-for-facet-edge-attributes/8481/2 "2020-12-23T18:28:51Z")

</div>

I think adding the type UID in facets is a valid request. Cuz it opens the possibility to do Hypergraphs. Ofcourse, the Hypergraph wouldn’t be “native” as facets aren’t first-class citizens. But it would be great for users who wanna explore the Hypergraph concepts.

# What I have tried to reproduce here

```auto
{
  set {
    _:alice <name> "Alice" .
    _:alice <friend> _:bob (close=true, relative=false) .
    _:bob <name> "Bob" .
    _:charlie <name> "Charlie" .
  }
}

```

One thing to add is give blank nodes support in facets. e.g.:

```auto
{
  set {
    _:alice <name> "Alice" .
    _:alice <friend> _:bob (close=true, relative=false, Presentedby="_:charlie") .
    _:bob <name> "Bob" .
    _:charlie <name> "Charlie" .
  }
}

```

So what I did to add the UID was.

```auto
upsert {
  query {   
    q(func: uid(0x2735)) {
     v as uid
      name 
      friend @facets {
         b as uid
         name
      }
    }
  }

  mutation {
    set {
      uid(v) <friend> uid(b) (close=true, relative=false, Presentedby=0x2737) .
    }
  }
}

```

Also, another good way would be

```auto
upsert {
  query {
    
    CH as varg(func: eq(name, "Charlie"))
    
    q(func: uid(0x2735)) {
     v as uid
      name 
      friend @facets {
         b as uid
         name
      }
    }
  }

  mutation {
    set {
      uid(v) <friend> uid(b) (close=true, relative=false, Presentedby=uid(CH)) .
    }
  }
}

```

# Worth to mention

Dgraph converts the UID to Hex. In my case it had converted `0x2737` to `10039`

# The Final Facet format with UID type.

```auto
{
   "data": {
      "q": [
         {
            "uid": "0x2735",
            "name": "Alice",
            "friend": [
               {
                  "name": "Bob",
                  "friend|Presentedby": {
                     "uid": "0x2737"
                  },
                  "friend|close": true,
                  "friend|relative": false
               }
            ]
         }
      ]
   }
}

```

---

<div class="post-metadata">

**Author:** ![monstermunch](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/monstermunch/32/7561_2.png) [@monstermunch](https://discuss.dgraph.io/u/monstermunch)\
**Post date:** [April 9, 2021, 2:46pm UTC](https://discuss.dgraph.io/t/please-support-uid-type-for-facet-edge-attributes/8481/3 "2021-04-09T14:46:50Z")

</div>

Our team is trying to create a hypergraph to represent repeated consistent relationships between nodes. I know we can do this in Neo4J, but cost is an issue here, especially since this is a PoC. A UID feature for the edge is essential - Is there any workaround for this right now? I guess we could create a node that is an ‘edge’, but it makes traversal strange.

---

<div class="post-metadata">

**Author:** ![Daniel](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/daniel/32/8499_2.png) [@Daniel](https://discuss.dgraph.io/u/Daniel)\
**Post date:** [September 12, 2021, 12:37pm UTC](https://discuss.dgraph.io/t/please-support-uid-type-for-facet-edge-attributes/8481/4 "2021-09-12T12:37:34Z")

</div>

@MichelDiz and team, did you give this issue any more thought?

In the RDF world, RDF-star is getting more traction, supporting a fuller range of values for edge properties / facets:

[https://blog.liu.se/olafhartig/tag/rdf-star/](https://blog.liu.se/olafhartig/tag/rdf-star/)  
[https://w3c.github.io/rdf-star/cg-spec/2021-04-13.html](https://w3c.github.io/rdf-star/cg-spec/2021-04-13.html)

As a possible workaround, could one have a convention such as #id that would somehow automatically retrieve linked nodes?

```auto
{ 
    id: Norway,
    yearOfIndependence: 1905,
    yearOfIndependence|source : "id#wikipedia" 
}

If facetValue.beginsWith(id#):

facetGetLinkedNode( func(id(wikipedia)) ) {
   id...
}

```

But I guess the more tricky part would be to keep this in sync if the ID/UID is removed/changed etc … Any ideas appreciated!
