Skip to main content
main-content
Top

About this book

Learn the best way of writing code to run inside a relational database. This book shows how a holistic and set-oriented approach to database programming can far exceed the performance of the row-by-row model that is too often used by developers who haven’t been shown a better way.
Two styles of programming are encountered in the database world. Classical programming as taught in many universities leads to an atomic, row-oriented, and procedural style inspired by the structured models of programming. In short, many application developers write in the relational database exactly like in the user interface. The other style of programming is holistic, data set oriented, and coded mainly in SQL. This is the style of the database developer.
The set based and holistic style of development is not promoted enough in universities, and many application developers are not fully aware of it. There are many performance issues all over the world in relational databases due to the use of the atomic and inappropriate style of programming. This book compares the two styles, and promotes the holistic style of development as the most suitable one. Examples are given to demonstrate the superiority of a set-based and holistic approach.Compares the two styles of development
Shows the performance advantages of set-based development
Solves example problems using both approachesWho This Book Is For
Two Styles of Database Development is aimed at application developers willing to adapt their programming styles in return for better-performing applications. It’s for students and new developers wanting to position themselves as having database expertise and build a reputation for developing highly-performant database applications.

Table of Contents

Chapter 1. The Concept of Style

Abstract
Nowadays, being a programmer is considered a very good career, and more and more people are choosing this path. Like anything in life, writing software code is an activity that is influenced by many factors, both subjective and objective. Many programmers do their work in a certain way according to their experience, knowledge, and preferences. Many embrace a certain style of writing code that is more or less correlated to the application they are creating. Writing a game for children is different than working on a team of developers in an ERP, for example.
Stefan Ardeleanu

Chapter 2. SQL: Beauty and the Beast

Abstract
In the first chapter, I analyzed the table design, including the layer of constraints, and I concluded that this is actually the beginning of the development process. Database development includes database design and we cannot analyze one without the other.
Stefan Ardeleanu

Chapter 3. A Holistic Vision of the Data

Abstract
I will continue with the theoretical discussions about the two styles of development and I will introduce you to the key concept behind one of the styles of development. This is the concept that identifies one style against the other: the concept of the data set. I will explain that the concept of style, despite its degree of subjectivity, is a notion that should be analyzed by a variety of professionals in a variety of environments, starting with IT universities and continuing with software companies.
Stefan Ardeleanu

Chapter 4. Data by Set or by Row?

Abstract
This book is divided in two parts. The first part describes the concepts and the second part illustrates these concepts with practical examples. With these examples I want to show that, very often, the same task within a database can be done either using the atomic style of programming, a common style used by many application developers, or using the holistic approach for data access, the true SQL style of programming, a style that is specific to authentic database programmers but should be used by any kind of programmer working at the database level. You will see that this latter style of programming is much simpler and more accurate. The code is much simpler, the performance is better, and the code is highly portable from one database system to another. Actually, I don’t see any advantage of the atomic approach over the holistic approach (of course, these considerations apply to the specific context of relational database development).
Stefan Ardeleanu

Chapter 5. Data Transfer Paradigm

Abstract
Starting with this chapter, I will demonstrate the two styles through a variety of examples. These examples will make the distinctions very clear. My main goal in this book is to clarify the two styles of development, to show the differences between them, and to show the advantages and disadvantages of each. I also intend to promote the holistic style. Please feel free to experiment with applying the two styles.
Stefan Ardeleanu

Chapter 6. The Challenge of Scalar Functions

Abstract
The cursor is the main feature that allows the application developer to move the entire context to the row level. From my point of view, when teaching application developers to work in the database, I would completely remove the cursor from their work agenda and forbid the use of it until they learn and understand the concept of the data set. I would also remove the loop feature from their development activity and not allow them to loop under any circumstances. Cursors with loops are the favorite tools of many application programmers, who like to use them often because they handle things atomically.
Stefan Ardeleanu

Chapter 7. Writing SQL vs. Writing Procedurally

Abstract
This chapter offers more examples of the two styles of development. I will use the same simple design taken from an inventory database: two tables that store products and product types.
Stefan Ardeleanu

Chapter 8. Row Triggers and the Need for Atomic Solutions

Abstract
Any relational database has a variety of logical and procedural objects, some of them quite classic and inherited from other languages, like the scalar function or stored procedure. The scalar function is clearly oriented per row, so it is an atomic object. Apart from the traditional objects, there are database-specific objects, and the trigger is maybe the most common one. As you probably know, there are many types of triggers, such as statement triggers and row triggers. In a way, the row trigger is very similar to the scalar function, because it is a row-oriented object. In this chapter, you will see how row triggers work and how they move the context to the row level whether we like it or not.
Stefan Ardeleanu

Chapter 9. Final Reflections and Thoughts

Abstract
I am not a guru. What I am is a passionate and dedicated SQL person. I spent many years in SQL development and I developed my own style. During these years, I gathered many experiences, discovered many ideas, and rediscovered the wheel many times. I know very well that most of the ideas explained here are well known to many professionals all over the world. However, I hope to offer a better view and I hope clarify some of our realities.
Stefan Ardeleanu
Additional information