O'Reilly logo

Agile Database Techniques: Effective Strategies for the Agile Software Developer by Scott Ambler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 19. Implementing Referential Integrity and Shared Business Logic

It's not just a black and white issue; there are also shades of gray. Furthermore, last time I looked there's a whole spectrum of colors out there as well.

Referential integrity (RI) refers to the concept that if one entity references another, then that other entity actually exists. For example, if I claim to live in a house at 123 Main Street, then that house must actually be there, otherwise I have an RI error. In relational database design, the referential integrity rule (Halpin 2001) states that each non-null value of a foreign key must match the value of some primary key.

In the 1970s, when relational databases first came on the scene, the standard implementation technology was procedural languages such as PL/1, Fortran, and COBOL. Because these languages didn't implement anything similar to data entities and because the relational database did, it made sense that relational databases were responsible for ensuring RI. Furthermore, relational databases back then were relatively simple: they stored data and supported the ability to implement basic RI constraints. The end result was that business logic was implemented in the application code, and RI was implemented in the database.

Modern software development isn't like that anymore. We now work with implementation languages such as C# and Java that implement entities called classes. As a result, RI also becomes an issue for your application code as well as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required