LogiQL and SQL - Halpin, Terry; Rugaber, Spencer (Taylor & Francis Group, 2015)
SQL is a standard language used for defining, manipulating, and querying relational databases. This appendix provides a brief discussion of how basic queries conveyed in SQL may be expressed in LogiQL. Consider the following relational database, which includes two relational tables (Tables H.1 and H.2) describing countries in 2011. The country table lists the ISO two-letter code, name, and population of various countries. For discussion purposes, the population of Finland (5,396,292) is omitted simply to illustrate SQL’s use of a null value to indicate that a data value is missing (e.g., because it is unknown or inapplicable). To save space, only a small number of countries are included. For those countries that have presidents, the president table lists the name, country, gender, and birth year of those presidents. Australia, Canada, and the United Kingdom have prime ministers instead of presidents, so they are not included in the president table. Throughout the database, countries are standardly identified by their country codes. The entries in the first two columns of the tables are necessarily unique, so each of these columns is a candidate key for its table. The country table has countryCode as its primary key and countryName as an alternate key.