"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Chapter 3. SQL BasicsYou might have noticed that I barely mentioned SQL in the preceding chapter. Remember this equation: SQL SQL is based on the relational model but doesn't implement it faithfully. One departure from the model is that in SQL, primary keys are optional rather than mandatory. Consequently, tables without keys will accept duplicate rows, rendering some data inaccessible. A complete review of the many disparities is beyond the scope of this book (see the "Learning Database Design" sidebar in "Tables, Columns, and Rows" in Chapter 2). The upshot of these discrepancies is that DBMS users, and not the DBMS itself, bear the responsibility for enforcing a relational structure. Another result is that the Model and SQL terms in Table 2.1 in Chapter 2 aren't perfectly interchangeable.With that warning, it's time to learn SQL. An SQL program is a sequence of SQL statements executed in order. To write a program, you must know the rules that govern SQL syntax. This chapter explains how to write valid SQL statements and also covers data types and nulls. |