wen liu
wen liu

Reputation: 31

Database design: ordered set

task_set is a database with two colums(id, task):

 id    task 
  1     shout
  2     bark 
  3     walk
  4     run

assume there is another table with two colums(employee,task_order)

task_order is an ordered set of tasks, for example (2,4,3,1)

generally, the task_order is unchanged, but sometimes it may be inserted or deleted, e.g, (2,4,9,3,1) ,(2,4,1)

how to design such a database? I mean how to realize the ordered set?

Upvotes: 1

Views: 109

Answers (1)

Zohar Peled
Zohar Peled

Reputation: 82474

If, and ONLY if you don't need to search inside the task_set column, or update one of it's values (i.e change 4,2,3 to 4,2,1), keeping that column as a delimited string might be an easy solution.

However, if you ever plan on searches or updates for specific values inside the task_set, then you better normalize that structure into a table that will hold employee id, task id, and task order.

Upvotes: 1

Related Questions