Creating Properties on Entities

Creating Properties on entities is achieved by using the create property statement. The statement defines 3 key elements:

  • The Uri of the property/relationship for the triple
  • The Type Uri of the triples’ object
  • The field of the incoming data where data is to be taken from

Basic Create Property statement

The basic create property statement takes the following form.

create property foaf:name as xsd:String with FirstName;

Alternatively, if the foaf ontology is included in the ontologies directory and defines a rdf:range for the foaf:name property, you can use:

create property foaf:name with FirstName;

In this form, it is expected that the language will be able to determine the range of the value from the rdf:range definition in the ontology.

Creating a Property with an Entity

The gfear language allows a property to be created where the object is an entity that has been created within the script. To learn more about creating entities, see Creating Entities.

The following code demonstrates how to create a property with an entity as the object.

create entity myPerson as foaf:Person with {
    create entity newProject as foaf:Project with
    {
       ...
    }

    create property foaf:currentProject with entity newProject;
}

The above code creates a new entity called newProject of type foaf:Project. This is then attaches it to the myPerson entity using the predicate foaf:currentProject.