Skip to content

Instantly share code, notes, and snippets.

@timabell
Last active October 21, 2019 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timabell/55ebbab29ea123c17f192bdbdec5aa44 to your computer and use it in GitHub Desktop.
Save timabell/55ebbab29ea123c17f192bdbdec5aa44 to your computer and use it in GitHub Desktop.
#!/bin/bash -v
# local version of:
# http://deckdown.org/deck?theme=solarized&src=https://gist.githubusercontent.com/timabell/55ebbab29ea123c17f192bdbdec5aa44/raw/whats-a-db.md#/2
pushd .
cd ~/repo/deckdown
PORT=3002 node deckdown.js &
pid[0]=$!
popd
python -m SimpleHTTPServer &
pid[1]=$!
sleep 2
xdg-open http://localhost:3002/
xdg-open http://localhost:8000/
xdg-open http://localhost:3002/deck?src=http://localhost:8000/whats-a-db.md
trap "kill ${pid[0]} ${pid[1]}; exit 1" INT
wait
# killing background jobs: https://stackoverflow.com/a/19274804/10245

Prep

cd ~/dfe/
./sse.sh

questions...

  • Who's written T-SQL before?
  • Who's used a database with other tools?
  • Who knows what a Foreign Key is
  • Who knows what a database table is
  • Who's heard of a relational database
  • Who's heard of a database

What is a Relational Database?

Charm Consulting Ltd Tim Abell https://timwise.co.uk/ @tim_abell

Mon 21st Oct 2019 for DfE

A fancy Spreadsheet

https://docs.google.com/spreadsheets/d/1bfRYaIbw1XfOpWheCZ0XRqs6_2J76LUvpsoDU7qQk48/edit?usp=sharing

  • Google sheets
  • MS Excel
  • Apple numbers
  • Airtable

But with "foreign keys"...

Show don't tell

A contrived example:

http://demo.schemaexplorer.io/

  • tables
  • columns
  • data
  • foreign keys

The real deal

The database behind

https://www.qa.publish-teacher-training-courses.service.gov.uk/

...

http://localhost:8888/manage_courses_backend_development/

...

https://c01b29de.ngrok.io/manage_courses_backend_development/

A layer closer

Structured Query Language (SQL)

select count(*) from course;
 count
-------
 36723
(1 row)

More SQL

select course_code, name from course limit 5;
 course_code |    name
-------------+-------------
 2VMB        | Mathematics
 2LGD        | History
 2SZK        | Biology
 3DCW        | Computing
 377R        | Music
(5 rows)

Even More SQL

select
	p.provider_code, p.provider_name,  c.course_code, c.name
from course c
	join provider p on p.id = c.provider_id
limit 5;
 provider_code |      provider_name      | course_code |           name
---------------+-------------------------+-------------+--------------------------
 1DT           | Aslacton Primary School | 25BL        | Primary
 1DT           | Aslacton Primary School | 25BN        | Primary with Mathematics
 1DT           | Aslacton Primary School | 2K6D        | Primary
 1DT           | Aslacton Primary School | 3DRK        | Primary
 1DT           | Aslacton Primary School | 3DZS        | Primary
(5 rows)

Okay I'll stop now...

https://www.w3schools.com/sql/

Questions?

Done done done!

Now you know what a relational database is. Tell all your friends.

Thanks

Charm Consulting Ltd Tim Abell timwise.co.uk @tim_abell

Mon 21st Oct 2019 for DfE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment