Register
Tuesday, March 09, 2010
 
 DBAs And ProgrammersBlog
  
News! Minimize
   
 
 Print   
 
Misc Blog Stuff Minimize
   
 
 Print   
 
The Reluctant DBA Minimize
 
 
 
 Print   
 
Reluctant DBA Minimize
   
 
  
 
Reluctant DBA Minimize
   
 
  
 
The Reluctant DBA Minimize
 
Author:CarpDeusCreated:4/18/2008 6:56 AM
As a programmer and database administrator, I've seen a lot and here I'll record bits of information about what I'm doing and how I'm overcoming various challenges

There has been a surge in recent years involving Test Driven Development, something that Mike Amundsen and I were discussing last night. It's not a development style that we work with much and that discussion led to this post and a new style of programming we call MDD, матрёшка doll development. матрёшка (Matryoshka) dolls are nesting dolls, looking something like this:

800px-Russian-Matroshka2

 

To understand the MDD, let's look at TDD and some of the reasons it seems to have exploded in popularity. One reason that I posited was that TDD is really great for quickly creating demo software. Create the stub of a class,...

Read More »

So, you've got an Azure SQL Database and have been doing some work in it/on it and then find out it is a CTP and you need to move the data and schema to another database.

Which isn't bad but there aren't any good tools for scripting an Azure SQL database, mostly because Azure SQL doesn't support using the DMO, which is what most people use.

So, I wrote my own.

It's not perfect, it's missing a few things (doesn't handle triggers, for instance) but it should be good enough to get you started.

AzureSQLScripter

It's simple enough. Download...

Read More »

The title of this post comes from an ad for one of those code generators that scans your database and creates an application with little to no work on the part of the developer. Sounds impressive, but what would impress more is the right 10,000 lines of code. Mark Twain said it best:

The difference between the almost right word & the right word is really a large matter--it's the difference between the lightning bug and the lightning.- Letter to George Bainton, 10/15/1888

The same goes for code. If you want a simple example, look at sorting algorithms. Bubble sort is the one that almost everyone comes across when first learning to sort data, and they quickly find that there are other ways to do it, some of which are more efficient in certain situations than others. The difference between the right sort routine and the wrong sort routine is the difference between a scalable program and one that has limitations.

...

Read More »

Luciano E. Guerche was recently lamenting the costs of changing frameworks, especially within the Microsoft world. He said:

If you want Winforms app to turn a WPF app? Rewrite it from scratch? Come on M$...

To which I replied:

(re)Writing from scratch enables you to avoid the bugs in the original app and write brand new ones! (yes, bugs)

It was tongue in cheek and very reminiscent of an old saw about bugs in code:

Every program has at least one bug and can be shortened by at least one instruction  from which, by induction, one can deduce that every program can be reduced to one instruction which doesn't work.

But it also had a couple of truths in it. Frameworks are wonderful things. Engineers and architects use frameworks all the time. The Statue of Liberty is copper over an internal framework of steel. But changing that framework isn't easy. And the same thing applies to writing code.

...

Read More »

I used to work in an office that had a pool table, one of those really expensive, championship caliber ones. Since it didn't cost me anything to use it, I would use it a lot as a break from my net time. And I come to some conclusions that I wrote back then. Not quite a "Everything I need to know I learned from pool" but some things that are as applicable now as they were 7 years ago.... Finesse can be more important than power. Oh how true. Like many things in life, I started out shooting pool by just trying to ram things through. I can be quite powerful and when I break with all my might, the balls scatter to the four corners of the table. But most of the time finesse is required over brute force. If you have the perfect shot lined up, particularly a straight shot, and power the ball into the pocket, odds are the cue ball will follow it in and you've wasted that shot. Remember the goal of the game. When I was in college, back in the mid-80s, I got hooked on 9-ball. The rules are simple. You have to hit the lowest...

Read More »

One of my friends was recently musing on whether they should attend DevLink or not and, in their musings, said it all depended upon what the SQL Tracks were going to be. For some reason, that particular incident reminded me of the parable of the Beam:

Judge not, that ye be not judged.For with what judgment ye judge, ye shall be judged: and with what measure ye mete, it shall be measured to you again.And why beholdest thou the mote that is in thy brother's eye, but considerest not the beam that is in thine own eye?Or how wilt thou say to thy brother, Let me pull out the mote out of thine eye; and, behold, a beam is in thine own eye?Thou hypocrite, first cast out the beam out of thine own eye; and then shalt thou see clearly to cast out the mote out of thy brother's eye.Matthew 7:1-5

Regardless of the original intent of the parable, I think it's very applicable to developers (myself included) when it comes to technology in general and programming languages in specific.

I would say that most developers...

Read More »

RowNumber() really is a great addition to SQL Server and has been very helpful in many of my applications. But I have been granted a new task, adding grouping within a sort. To explain the dilemma, let's look at some rows of data that are sorted in date order:

RecID GroupTag SortColumn RowNumber 1 NULL 2009/2/13    1 2 NULL 2009/2/13    2 3 GroupSet 2 2009/2/14    3 4 NULL 2009/2/14    4 5 GroupSet 2 2009/3/01    5 6 GroupSet 2 2009/3/10    6 7 GroupSet 2 2009/3/10    7 What I need to do is sort it so that RecIDs 5-7 show up between 3 and 4, because they belong to a group (defined by the GroupTag) and should be grouped together with the first record in the sort of that group.

To make things slightly easier, I'm actually selecting a subset of data and using the RowNumber() function to put it in order and support paging. The trick is to resort to adding a column called GroupSort to the data to apply grouping within either a temporary table or table variable. Now for the tricky part (or at...

Read More »

I know I've put a lot of Azure information in this blog and more people expect it to be geared more toward SQL Server and C#. So I've created a new website, AzureDBA.com, to host all of my Cloud Computing information; including, but not limited to:

  • Best Practices
  • Codes Samples
  • Forums for discussions

Stop by and join the discussion of what will be an important part of the next step in computer programming.

Josef

In my last post, A REST-ful Look at Azure (Part 8) Azure Hosted Services, I took a very brief look at the Web Role and a more in-depth look at the Worker Role. Today I'm going to explore some things you should do when implementing a Worker Role.

As I said in my last post, the Worker Role should be an extremely light wrapper that calls a class that does all of the real work. There are two good reasons for this. First, the less code in the Worker Role, the less debugging you need to do in the Development Fabric, the easier it will be to write, test and debug your code. Second, the code in the Worker Role should be fairly stable. If all it is doing is instantiating a class and calling it every few seconds, it lessens the chances of errors happening in the Cloud version that will require major changes. Follow the basic rule of Keep It Super Simple when it comes to your Worker Role.

The class that the Worker Role is instantiating should include a call back function (see my blog post Services, Worker Classes and Templates, Oh My from February 23, 2009 for more details) that serves two purposes. First, it allows the Worker Role to log information to the Cloud Logs but it also updates the DateTime value the Worker Role uses to determine it's not hung. Finally, it should also include a way for the Worker Role to notify it that a request has been made to stop processing.

My generic Processing Class simply queries Azure Queue Storage to see if there is a message to be processed. There may be more than one, but the Processing Class gets just one and processes it. When it has finished, it checks to see whether or not the boolean value stopProcessing is true. If it isn't, then it checks the queue for another message and starts the process all over again.

While this is the best solution we have at the moment, it's not the optimal one and will have to change as Azure Hosted Services comes out of the CTP stage and enters Beta or Release. A couple of items this doesn't address:

How responsive must a Worker Role be?If a Windows Service doesn't respond to a shutdown request in 30 seconds, it's considered "frozen" and Windows will instantly terminate the thread. It's unknown what the Worker Role will do or how long it will wait. It will probably be a requirement to handle a graceful shutdown that every time you call Notification you also check to see if you should stop processing. Continuation of processing.If the Worker Role ends in the middle of a request, how do you gracefully continue? How Idempotent is your processing? In this particular example, if the request isn't in Pending status, the worker role just says it is in error and doesn't do anything. Code Samples The complete sample code can be downloaded here.

First, we have the basic plumbing that handles sending notifications back to whatever is calling the class:

...

Read More »

You may disagree with the title of the post, but I think it is far more true than not. First, because I know folks are going to try to tell me, this doesn't apply if you're using S[S]DS (SQL Server Data Services), once it finally becomes available because it really is nothing more than SQL Server running on MS machines in the cloud. This is, of course, the same as if you were running SQL Server on Amazon hardware. But there's a major problem with SQL Server when it comes to scalability above a certain level, most of which I covered in Why Aaron Skonnard is Wrong About Azure Table Storage. And all of the things that make SQL Server bad for highly scalable web sites are the things we know as DBAs.

For instance, if you've ever heard Kimberly Tripp speak about database design, you've...

Read More »

 
 
 Print   
 
Privacy Statement | Terms Of Use Copyright 2001-2008 by ReluctantDBA.com