Skip to main content

Creating Predicates: Part 2

Our full application schema will contain 12 predicates.

We've already shown you how to create person/fullName and chat/messsage. In order to create the other 10 predicates, we'll need to use additional predicate predicates:

  • _predicate/unique - Is a predicate unique? true or false
  • _predicate/multi - Can a predicate include multiple objects (values)? true or false
  • _predicate/restrictCollection - If a predicate is of type ref, we can restrict it so that the references only refer to one type of subject. The value for this should be the name of the collection, i.e. "restrictCollection": "artist"

Application Schema Predicates#

The following is the full list of predicates we still need to create.

  • Predicates that should be unique are marked with a '*'.

  • Predicates that are of type, ref are marked with a '~'. See if you can figure out what collections those predicates should be referencing.

  • Predicates that are "multi": true are marked with a '+'.

Person:

  • person/handle *
  • person/follows ~ , +
  • person/favNums +
  • person/favArtists ~ , +

Chat:

  • chat/person ~
  • chat/instant
  • chat/comments ~ , +

Comment:

  • comment/message
  • comment/person ~

Artist:

  • artist/name *

Your job is to create the remaining 10 predicates. A few points:

  1. If a predicate is not unique, you don't have to list "unique": false. Predicates are not unique by default.
  2. If a predicate is not 'multi', you don't have to list "multi": false. Predicates are not multi by default.
  3. true and false do not need to be surrounded by quotation marks. In most programming languages, and in FlureeQL, true and false are special keywords.
  4. Remember, the types we are using are: string (text), int (numbers), ref (reference), and instant (time).

Create All 10 Predicates Above

Write a transaction to create the 10 predicates we need for our chat application schema.