patternMinor
Which database type to use
Viewed 0 times
whichusedatabasetype
Problem
I want to implement database for following application:-
User creates task and assigns to other user who can furthur split it into subtasks and assign it to other users.creaking a tree like structure.
Should i use graph database or what?
User creates task and assigns to other user who can furthur split it into subtasks and assign it to other users.creaking a tree like structure.
Should i use graph database or what?
Solution
You could use a graph database, or a plain old relational one:
Create a task:
Assign a task:
Split up a task:
Complete a task:
I would recommend PostgreSQL, as it can handle hierarchical data better than MySQL
/* set parent_id for child tasks */
create table task (
id serial primary key,
parent_id integer null references task(id),
subject text not null,
body text null,
due_at date null
);
create table task_role_type(
id smallint primary key,
name text not null
);
insert into task_role_type values
(1, 'Created By'),
(2, 'Assigned To'),
(3, 'Completed By');
create table task_role (
task_id integer not null references task(id),
party_id integer not null references party(id),
role_id smallint not null references task_role_type(id),
from_date timestamp not null default current_timestamp,
to_date timestamp null,
primary key (task_id, party_id, role_id, from_date)
);Create a task:
insert into task (subject, due_at) values ('do stuff', '2013-02-18');
insert into task_role (task_id, party_id, role_id) values (1,1,1);Assign a task:
insert into task_role (task_id, party_id, role_id) values (1, 2, 2);Split up a task:
insert into task (parent_id, subject) values (1, 'do stuff B');
insert into task_role (task_id, party_id, role_id) values (2, 1, 1);Complete a task:
insert into task_role (task_id, party_id, role_id) values (1, 2, 3);I would recommend PostgreSQL, as it can handle hierarchical data better than MySQL
Code Snippets
/* set parent_id for child tasks */
create table task (
id serial primary key,
parent_id integer null references task(id),
subject text not null,
body text null,
due_at date null
);
create table task_role_type(
id smallint primary key,
name text not null
);
insert into task_role_type values
(1, 'Created By'),
(2, 'Assigned To'),
(3, 'Completed By');
create table task_role (
task_id integer not null references task(id),
party_id integer not null references party(id),
role_id smallint not null references task_role_type(id),
from_date timestamp not null default current_timestamp,
to_date timestamp null,
primary key (task_id, party_id, role_id, from_date)
);insert into task (subject, due_at) values ('do stuff', '2013-02-18');
insert into task_role (task_id, party_id, role_id) values (1,1,1);insert into task_role (task_id, party_id, role_id) values (1, 2, 2);insert into task (parent_id, subject) values (1, 'do stuff B');
insert into task_role (task_id, party_id, role_id) values (2, 1, 1);insert into task_role (task_id, party_id, role_id) values (1, 2, 3);Context
StackExchange Database Administrators Q#34878, answer score: 2
Revisions (0)
No revisions yet.