What is sql?
Databases In the past, databases mostly held boring stuff: census data, employee records, bank accounts, … Today, databases hold virtually all of humankind’s collected information Everything you’ve ever read, seen (or done according to Snowden) Everything on the web (cat pictures) Scientific data (mostly LHC stuff) Medical data and so on Corny art from: https://www.flickr.com/photos/datacorpltd/19556451409
Databases are interesting Databases use restricted programming languages One of the few places where non-Turing-complete languages are an advantage This leads to very terse programming and deep query-optimization problems Concurrency and Transactions are essential Many activities happen simultaneously Need to heavily utilize parallel programming techniques
What is the advantage to SQL not being Turing-Complete? Easier to optimize Easier to write Lies! SQL is Turing-complete I don't know what Turing-complete is
Data Models - Components Mathematical representation of the data Relational Models (CSV) = tables Semi-structured Models (XML, JSON) = trees/graphs Operations on data (what is allowed, i.e. comparisons, equality, math) Constraints (what types of data are allowed, and where)
Attributes (column headers) Relations are tables Attributes (column headers) name FavoriteShow Ian Stargate SG1 Cam True Detective Caleb GLTAS maybe Tuples (rows) Relation name shows
Schemas (sound familiar?) Relation schema = relation name and attribute list Optionally: types of attributes Example: shows (name, FavoriteShow) or shows (name TEXT, FavoriteShow TEXT) Database = collection of relations Database schema = set of all relation schemas in the database
Why Relations? Very simple model Often (but not always) matches how we think about data Abstract model that underlies SQL, the most important database language today
Database Schemas in SQL SQL is primarily a query language, for getting information from a database. But SQL also includes a data-definition component for describing database schemas.
What is the difference between: Record, tuple, and row Nothing (in the context of this class) The way they are spelled How insulting they are Whether the order of the elements matter