SQL and Relational Theory: How to Write Accurate SQL Code

I have just finished reading SQL and Relational Theory: How to Write Accurate SQL Code by C.J.Date. Here are some of my thoughts on the book.

The book can be a bit dense in places. The difficulty is that this book is written for database professionals not Oracle DBAs nor MS-SQL/Server DBAs nor MySQL DBAs. There is a great difference between knowing SQL and relational database theory. This book intends to address that gap in knowledge.

Chapter 4: No Duplicates, No Nulls

The position of No Duplicates, No Nulls is a contentous one, but a correct one. Date gives some examples where the presence of NULLs and duplicates give incorrect results.

The presence of duplicate rows in a table is problematic. Was the row added in error, or by purpose? What the presence of a duplicate mean anyway?

The problems with NULLs are that of missing information, and three-value logic.

Chapter 5: Base Relvars, Base Tables

The important part of this chapter is what I had been calling the external predicate. Date uses the term relvar predicate or intension (p.101).

This predicate is the intended interpretation – in the other words, the meaning, also called the intension (note the spelling) – for relvar S. (Italics in original)

Chapter 8: SQL and Constraints

Date is very insistent on type constraints to maintain the integrity of the data. Unfortunately, the current RDBMS products do not strictly support this.

Date wants integrity to be check at statement boundaries, not transaction boundaries.

Chapter 11: Using Logic to Formulate SQL Expressions

This was the most interesting chpater for me. The ways of translating logical expressions into SQL statements was an eye-opener. The use of the EXISTS operator can be quite hairy at times. The issue of how SQL handles empty sets is quite perplexing.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s