Appendix A. SQL fundamentals

 

This book assumes that you have a basic understanding of relational databases and the Structured Query Language (SQL). It will be easier for you to learn some of the advanced features of NHibernate if you already have a sound knowledge of SQL. This appendix gives a brief overview of the fundamentals of SQL. We highly recommend that you find a book to learn more about it.

Tables

A table, with its rows and columns, is a familiar sight to anyone who has worked with an SQL database. Sometimes you’ll see tables referred to as relations, rows as tuples, and columns as attributes. This is the language of the relational data model, the mathematical model that SQL databases (imperfectly) implement.

Relational model

The relational model lets you define data structures and constraints that guarantee the integrity of your data (for example, by disallowing values that don’t accord with your business rules). The relational model also defines the relational operations of restriction, projection, Cartesian product, and relational join. These operations let you do useful things with your data, such as summarize or navigate it.

Each of the operations produces a new table from a given table or combination of tables. SQL is a language for expressing these operations in your application (therefore called a data language) and for defining the base tables on which the operations are performed.

DDL and DML

Table operations

Queries