Math behind databases management and SQL ? Are there some mathematical theories/theorems/... behind modern development of database management systems and in particular of SQL ?
I am refreshing my knowledge of these things which are quite down-to-earth "how to use" (create table ..., insert..., select * from ...), but I think some deeper understanding what is behind would be helpful. 
In particular in Wikipedia one may find some relations with 3-valued logic: 

Along with True and False, the Unknown
  resulting from direct comparisons with
  Null thus brings a fragment of
  three-valued logic to SQL. The truth
  tables SQL uses for AND, OR, and NOT
  correspond to a common fragment of the
  Kleene and Lukasiewicz three-valued
  logic (which differ in their
  definition of implication, however SQL
  defines no such operation).

But it is not very clear for me what it means and how deep it is ?
 A: Relational algebra might be of your interest.
A: The course I took in Databases contained a large amount of deeper mathematical theory. It was taught by a mathematician turned computer scientist named Mike Rice at Wesleyan University, and notes/assignments used to be available online (but I can't find them any more). Anyway, the course textbook was Database: Principles, Programming, and Performance, Second Edition by Patrick O'Neil and Elizabeth O'Neil. The first chapter in particular is almost entirely math, and that's leads into relational algebra and then into table joins, etc. While developing the theory the book also teaches programming in SQL.
I really can't recommend this book highly enough. This was exactly the approach I needed as a mathematician trying to learn databases. After the course ended I did a summer job entailing a lot of work with databases and definitely felt my background was strong enough to do this work. I also lent the book to a friend who was transitioning from a math major to a job in databases and he felt the same way even though he was using SAS for that job.
A: If you google 'Theory of SQL' there are numerous references and one in particular refers to a PDF file.
But I think that the simplest way to look at it is to think in terms of what a database consists of:- 
1) each table is a set containing unique data (sometimes with indices on the tables)
2) various tables many be linked by references.
SQL then generates the tuples relating to the specific query from the relevant tables, the actual processing is usually hedden by the DBMS.
So you need to look at Set Theory, Combinational Algorithms(Knuth) and Relational Theory.
As an aside I used SQL for some 20 years in a number of databases.
Hope that this helps.
Ron
A: David Spivak (who is an occasional contributor here) has done some work on categorical aspects of database management, and the creation of dictionaries between math world and the DB world that allow one to prove that certain operations are well-behaved in a robust sense.  The link gives a list of his ArXiv papers.
