Skip to Content
Refactoring SQL Applications
book

Refactoring SQL Applications

by Stephane Faroult, Pascal L'Hermite
August 2008
Intermediate to advanced content levelIntermediate to advanced
298 pages
9h 22m
English
O'Reilly Media, Inc.
Content preview from Refactoring SQL Applications

Chapter 4. Testing Framework

You see, Ive got her pronunciation all right; but you have to consider not only how a girl pronounces, but what she pronounces.

—George Bernard Shaw (1856–1950)

Pygmalion, Act III

BEFORE I EMBARK ON THE TOPIC OF SURGICALLY REMODELING SQL STATEMENTS AND PROGRAMS, I need to discuss a topic of great practical importance: how to define a framework for testing, an environment to check that rewrites are not only faster, but also functionally equivalent. In theory, you should be able to mathematically prove that a relational construct is equivalent to another construct. Actually, many features of the SQL language are not relational in the strictest sense (there’s order by to start with; there is no order in a mathematical relation), and in practice, quirks in database design make some queries bear only a faint resemblance to what they’d look like in an ideal world. As a result, you have to resort to the usual tactics of program development: comparing what you get to what you expected on as wide a variety of cases as possible. Except that such a comparison is much more difficult with tables than with scalar values or even arrays.

Because refactoring is, by nature, an iterative process (changing little thing after little thing until performance is deemed acceptable), we need tools to make iterations as short as possible. In this chapter, I will address first the issue of generating test data, and then that of checking correctness.

Generating Test Data

Among the important ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

RESTful Java Web Services - Third Edition

RESTful Java Web Services - Third Edition

Balachandar Bogunuva Mohanram
Modernizing Enterprise Java

Modernizing Enterprise Java

Markus Eisele, Natale Vinto
Ultra-Fast ASP.NET 4.5

Ultra-Fast ASP.NET 4.5

Richard Kiessig

Publisher Resources

ISBN: 9780596514976Supplemental ContentErrata Page