0

I'm designing Sticky notes Management Application (CRUD), where StickyNote has 3 attributes, heading, summary and task list. The task has 2 attributes - heading and summary.

A sticky note can have upto 1000 tasks.

The class would look like -

public class StickyNote {

    String id;

    String heading;

    String summary;

    Set<Task> tasks;

}

When it comes using Database , to me a NoSql/Document structure seems more close to OOPS.Thus having one table representing StickyNote, with Task as a field/column.

Pros of this approach -

  1. Deletion - As multiple sticky notes can have same tasks, thus deletion of task could be straightforward, by providing task heading and sticky notes id.

  2. No need of introducing a second table for tasks. Hence either avoiding duplicate records or foreign key constraint check while deleting.

  3. Update - a task would be updated either using task heading or task summary. Thus iterating over the task list, and as max tasks could be 1000, performance won't be an issue.

Cons -

  1. Using id for deleting task is straightforward and performance efficient, rather than using iterator.

Questions-

  1. Would introducing Task table would be performance efficient?
  2. Would relational approach be some how better than non relational one?
  3. If I consider to scale up application, using million users in concurrent environment, introducing a Task id would be mandatory as iteration would then degrade performance, which essentially would lead to add a separate Task Table. Hence in that case both nosql and sql approach would be same?

1 Answer 1

0

Answers I found, after trying both relational and non relational approaches -

The best solution here is to introduce new table in Tasks rather than using embedded structure. This facilitates in performing CRUD operations on the task without iterating over collection (using @Id attribute), hence making it performance efficient. However if only seldom read only operations are needed on tasks, document structure is best suited.

Hence in no case, Nosql and Sql approaches are would be same. Nosql is best suited for unstructured data, where the unstructured data is seldomly updated. As soon as the unstructured data needs frequent updates, it is better to structure for efficiency.

Regarding the duplicate records- use @Id attribute of Tasks as reference in StickyNotes and remove the referenced item when deleted.

Not the answer you're looking for? Browse other questions tagged or ask your own question.