Courses/Computer Science/CPSC 203/CPSC 203 2007Summer L60/CPSC 203 2007Summer L60 Lectures/Lecture 7

Lecture 7

 * Query Language
 * How to produce a query
 * Text Readings: Chapter 9 "Circuits" pp 386-393

Glossary
has five key terms in any SQL statement
 * SQL (Structured Query Language)Terms
 * Select (Which Columns)
 * From (Which Tables)
 * Where (Which Rows)
 * Group By (Which Group Fields)
 * Having (Which Groups)
 * Terms of Boolean Logic
 * And
 * OR
 * NOT
 * XOR
 * Boolean Logic
 * Circuit

The terms of Boolean Logic were illustrated by their respective Truth Tables. See also Wikipedia: http://en.wikipedia.org/wiki/Truth_table (note that in class we used 1 where they use "T", and we used 0 where they use "F"). Truth table values were then related to Logic gates: http://en.wikipedia.org/wiki/Logic_gates. Finally, logic gates were combined to build more complex circuit diagrams : http://en.wikipedia.org/wiki/Logic_gates.

For more on Boolean Logic please see: http://en.wikipedia.org/wiki/Boolean_Logic

Queries
Trace (Query Evaluation)Steps

Basic: Summarize Data:
 * 1) Cross product from tables in 'FROM' (like the Union set)
 * 2) Remove rows when 'WHERE' is false
 * 3) Return true rows according to 'SELECT'
 * 1) Arrange rows by 'GROUP BY'
 * 2) Remove rows where 'HAVING' is False
 * 3) 1 Row for each true group according to 'SELECT'

Examples of the Trace mechanism were illustrated through a series of increasingly complex queries beginning with all data in a single table, to queries asking for summary data across several tables.

Resources
For database resources see Lecture 4

The primary resource for this lecture was:
 * Onest Zeros -- Understanding Boolean Algebra, Digital Circuits and the Logic of Sets. 1998. By John R. Gregg

Supplementary References are:


 * Logic. A Very Short Introduction. 2000. By Graham Priest.
 * Logic Made Easy. How to Know When Language Decieves You. 2004. By Deborah J. Bennett.
 * Feynman Lectures on Computation. 1996. By Richard P. Feynman.