Unique Identity Across Multiple Tables
This week had been a busy one; we had three deliverables; one internal app and two clients app. Due to training sessions; things get screwed up; it got hard to find the time…I was checking my timesheets; and wow! I have given about 50% extra time to the office this week <geez/>
One of these three was solely my baby, I am lucky that it was ASP.NET v2 app; and you guys will not believe that I made it in just four sessions of about 2/3 hours each; it was quite a bulky one; a complete administrative console of the system. Thanks to SqlDataSource, DataBinding and Visual Studio.NET designer; it saved many hours. The interesting stuff is that for this whole app; I had two write very few lines of code; I guess its not more than 500; all the remaining stuff was generated by the VS.NET. I am not proud of what I have done; but who cares? As long as it’s working!
Update: The app was a web interface above the data tier being accessed using stored procedures; I must say that the real magic is in stored procedures and that heavy lifting was already done before!
Just a small tip for my readers / colleagues. If you happen to have a scenario where there are multiple base tables of a given view; and multiple tables of the views are “hot” (i-e new data can be inserted) and you want to have an identity key that remains unique across multiple “hot” tables; the simplest thing you can do is to set increments of identity values in base tables; e-g if there are two tables; you can have +2 value for increment in each table; add one entry manually into one table before setting the increment; this way one table will have even values in identity field and the other will have odd values. You can now extend this idea across as many tables as you like!