Welcome to MSDN Blogs Sign in | Join | Help

Agile Database Development

Agile development at MSFT and tid bits about VSTE for DB Pros

Syndication

Tags

    No tags have been created or used yet.
Testing the Edges

I am sitting in a session on WCF now but just have to keep blogging about this cool product we have.  In the last post I talked about using regular expressions and the value of "human readable" vs. schema correct tests.  Let me illustrate another way that data gen can help you root out edge cases in your database. 

By default we generate for the entire valid range of a type.  For instance in Northwind the Order Details table has a UnitPrice field that is money type and this can range between 0 and 922337203685477.5807 by default and a quantity which is a smallint that therefor can be between 1 and 32767.  That all seems cool, generate data that is legal in the legal range and everything should be cool.   But if you do this, you can quickly find problems with poorly written code (yes, northwind isn't perfect yet...we are working at it). 

Northwind has a view called Invoices that creates a computed field:

(CONVERT(money, ([Order Details].[UnitPrice] * [Order Details].[Quantity] * ( 1 - [Order Details].[Discount]) / 100)) * 100) AS [ExtendedPrice],

So, you run the data generation without changing any settings then do a quick

select * from Invoices

and you will get:

.Net SqlClient Data Provider: Msg 8115, Level 16, State 2, Line 1 Arithmetic overflow error converting expression to data type money.

Whoops, if I have a UnitPrice that is 1/2 the max for money and you buy 3 of them, you are Bill Gates afterall, you just blew the system.  That means a couple things, either the UI programmer has to write a bunch of code to catch and handle your mistake or you need to create constraints and rules in your data tier to make sure this doesn't happen.  The Data Generator will follow constraints.  If you only expect products to code between 1 and 1000 dollars and set that as a constraint in the DB we will set the generator constraints to match.  Of course I can make my datagen work fine, just enter manual constraints on the data I generate but is instructive to use the defaults and see if your database performs the way you think it does. 

 

Published Monday, June 12, 2006 2:05 PM by thomas murphy

Comments

# re: Testing the Edges @ Monday, June 19, 2006 8:02 PM

I am really looking forward to the Data Generator piece of Data Dude - thanks for the info!

HintonBR

# Agile Database Development Testing the Edges | Paid Surveys @ Friday, May 29, 2009 3:16 PM

PingBack from http://paidsurveyshub.info/story.php?title=agile-database-development-testing-the-edges

Agile Database Development Testing the Edges | Paid Surveys

Anonymous comments are disabled
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement  
Page view tracker