I have users that are grouped together in a team to work on a project together.
I am creating a schema to track when each team member on the projects has:
- seen a task
- completed the task.
This is the schema that I have come up with so far:
Dgraph Schema
Name: string .
IsOwnedBy: uid .
TeamMembers: [uid] .
HasTasks: [uid] .
Seen: bool .
Completed: bool .
type User {
Name
}
type Project {
Name
IsOwnedBy
TeamMembers
HasTasks
}
type Task {
Name
}
type TeamMember {
Name
HasTasks
}
I can add some data to the graph:
Data Mutation
{
set {
_:jack <Name> "Jack" .
_:jack <dgraph.type> "User" .
_:jill <Name> "Jill" .
_:jill <dgraph.type> "User" .
_:project1 <Name> "Do All The Tasks" .
_:project1 <dgraph.type> "Project" .
_:project1 <IsOwnedBy> _:jack .
_:jack <TeamMember> _:project1 .
_:jill <TeamMember> _:project1 .
_:task1 <Task> "The First Task" .
_:task2 <Task> "The Second Task" .
_:project1 <HasTasks> _:task1 .
_:project1 <HasTasks> _:task2 .
_:jack <HasTasks> _:task1 (seen=false, completed=false) .
_:jack <HasTasks> _:task2 (seen=false, completed=false) .
_:jill <HasTasks> _:task1 (seen=false, completed=false) .
_:jill <HasTasks> _:task2 (seen=false, completed=false) .
}
}
But the result is not really what I was expecting.
A Project should have a list of “Tasks”. And then the Users who are also TeamMembers should have a copy of all of the tasks when they are added to the project so that they can mark whether they have “seen” and then “completed” those tasks. Each TeamMember must complete each task.
I think my brain is still stuck in the RDBMS world.
- Do I even need a “TeamMember” type?
- Or would the TeamMember just be a list of Users?
- How would each TeamMember get a copy of the Tasks?
- Or perhaps each TeamMember just has an edge to each task and facets that indicate “seen” and “completed”…