WHAT IS SQL DATABASES In the past databases
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/photo s/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? 1. 2. 3. 4. 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 RELATIONS ARE TABLES headers) Tuples (rows) name Favorite. Show Ian Stargate SG 1 Cam True Detective Caleb GLTAS maybe Relatio n name shows
SCHEMAS (SOUND FAMILIAR? ) • Relation schema = relation name and attribute list • • Optionally: types of attributes Example: shows (name, Favorite. Show) or shows (name TEXT, Favorite. Show 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 1. 2. 3. 4. Nothing (in the context of this class) The way they are spelled How insulting they are Whether the order of the elements matter
- Slides: 10