Main types: Job, Company, Candidate …
I’d like to store status information (which can be represented in multiple edges/fields, such as whether the status is active, the name of the status) on each of these main types. Which solution would you recommend (or your own solution) and why?
1:
I have a Status type to describe the status of the above types.
type Status {
name: String # eg "Active Client" (for Company), "Searching" (for Candidates)
isActive: Boolean
...
}
Each main type has a one-to-one relationship with a Status type.
type Job {
...
status: Status
}
This is a bit annoying though: if I want to update the status, I’d have to fetch the status object’s UID and mutate the status node (I do not want to create a new status object every time the status changes, and have redundant status nodes that are never used and hang in the system).
But is it possible in a mutation, to make it so dgraph will update (if it exists, else create) the status object in the Job type, without having to use UID or any ID specifier?
2:
Similar to the above, but the Status node’s data is flattened into each main type.
type Job {
...
statusName: String
statusIsActive: Boolean
}
type Company {
...
statusName: String
statusIsActive: Boolean
}
This means I won’t have to reference any UIDs or IDs when I want to change status-related information, since it’s just stored as predicates.
An issue with this is solution is if I want to change the representation of status-type information (eg more status-related fields, such as whether the date of the status update), I’d have to manually do it across all the main types.
3:
I define an interface for Status instead of using a type.
All the main types implement this interface.
An issue is that the schema doesn’t read well, and it isn’t intrinsic that a Company implements a Status (makes more sense that the Company owns the Status).
interface Status {
...
statusName: String
statusIsActive: Boolean
}
type Company implements Status {
...
}
type Job implements Status{
...
}