Friday, December 21, 2007

A sequence column

I learnt something from one of our senior developers from Elcom. Let me give you an example.
Say we have a very simple table called MenuItem which may contains:
  • MenuID
  • MenuName

This table may be used to populate the menu items on top of each web pages. Now if we want to order the menu items, we need to add a sequence column, so you may want to add 1,2,3... for each items in the menu table. Now what if we want to add an item in future that needs to be in between of these items, you will need to reorder a lot of the columns, so instead of add 1,2,3.. you can add 10,20,30.. so that you have more flexibility in the future. Another thing is that since the number of menu items will be very limited, the data type should be tinyint.

blog comments powered by Disqus