#
Defining Schemas
Modeling data into a graph starts with defining node and edge schemas. In a Curiosity Data Connector, this is typically done using C# classes with attributes.
#
Node Schemas
Use the [Node] attribute to define a class as a graph node. Use [Key] to specify the unique identifier field.
[Node]
public class Device
{
[Key] public string Name { get; set; }
}
[Node]
public class SupportCase
{
[Key] public string Id { get; set; }
[Property] public string Summary { get; set; }
[Property] public string Content { get; set; }
[Timestamp] public DateTimeOffset Time { get; set; }
}
#
Edge Schemas
Edges define the relationships between nodes. It is recommended to use a static class with constants for edge names.
public static class Edges
{
public const string HasPart = nameof(HasPart);
public const string PartOf = nameof(PartOf);
public const string HasSupportCase = nameof(HasSupportCase);
public const string ForDevice = nameof(ForDevice);
}
#
Synchronizing Schemas
You can synchronize these definitions with the graph database:
await graph.CreateNodeSchemaAsync<Nodes.Device>();
await graph.CreateEdgeSchemaAsync(typeof(Edges));