<commit_before>---
layout: lecture
title: Databases
---

section.center data-background="#000"
  h2.white Databases

section.center data-background="#F00"
  h2.white Questions

section.center data-background="#F00"
  h2.white What is a protocol?

section.center data-background="#F00"
  h2.white What are the essentials of HTTP?

section.center data-background="#F00"
  h2.white How can you serve content at a specific URL using Sinatra?

section.center
  h2 The right weapon
  p (relational|object|graph|document) database

section.center
  h2 Relational databases
  p PostgreSQL, MySQL, Microsoft SQL Server, SQLite, ...

section.center data-background="#AED6FF"
  h2.white SQLite

section.center data-background="#000"
  h2.white Databases

section.center
  h2 A home for your data

section.center
  h2 Data structure

section.center
  h2 Kind of like arrays and hashes

section.center
  h2 Much more complex

section.center
  h2 Optimized for storing lots of data

section.center
  h2 Optimized for retrieving lots of data very, very fast

section.center
  h2 Allows building inner connections between parts of the data

section.center
  h2 Give me the thing that does something and is located somewhere along with its neighbours

section.center
  h2 Key components

section.center
  h2 Table (relation)

section.center
  h2 Column (attribute)

section.center
  h2 Row (record)

section.center
  h2 A table packs entities with common attributes

section
  pre
    '
      +----------------------------------------+
      |               Student                  |
      +------------+-----------+-----+---------+
      | First name | Last name | Age | Address |
      +------------+-----------+-----+---------+
      | Joe        | Somebody  | 20  | Street  |
      +------------+-----------+---------------+

section.center
  h2 Relating tables

section.center
  h2 primary key -> foreign key

section.center
  pre
    '
      +---------------------------------------------+
      |                  Student                    |
      +----+------------+-----------+-----+---------+
      | id | First name | Last name | Age | Address |
      +----+------------+-----------+-----+---------+
      | 1  | Joe        | Somebody  | 20  | Street  |
      +----+------------+-----------+---------------+

section.center
  pre
    '
      +------------------------------------------------------+
      |                       Student                        |
      +----+------------+-----------+-----+---------+--------+
      | id | First name | Last name | Age | Address | School |
      +----+------------+-----------+-----+---------+--------+
      | 1  | Joe        | Somebody  | 20  | Street  | Some   |
      +----+------------+-----------+---------------+--------+

section.center
  pre
    '
      +---------------------------------------------+
      |                  Student                    |
      +----+------------+-----------+-----+---------+
      | id | First name | Last name | Age | Address |
      +----+------------+-----------+-----+---------+
      | 1  | Joe        | Somebody  | 20  | Street  |
      +----+------------+-----------+---------------+

      +-------------------------+
      |          School         |
      +------------+------------+
      | Student id | School     |
      +------------+------------+
      | 1          | Joe        |
      +------------+------------+

section.center
  pre
    '
      +---------------------------------------------+
      |                  Student                    |
      +----+------------+-----------+-----+---------+
      | id | First name | Last name | Age | Address |
      +----+------------+-----------+-----+---------+
      | 1  | Joe        | Somebody  | 20  | Street  |
      +----+------------+-----------+---------------+

      +---------------------------------------------+
      |                   School                    |
      +------------+------------+---------+---------+
      | Student id | School     | Address | Type    |
      +------------+------------+---------+---------+
      | 1          | Joe        | Street  | Primary |
      +------------+------------+---------+---------+

section.center
  pre
    '
      +---------------------------------------------+
      |                  Student                    |
      +----+------------+-----------+-----+---------+
      | id | First name | Last name | Age | Address |
      +----+------------+-----------+-----+---------+
      | 1  | Joe        | Somebody  | 20  | Street  |
      +----+------------+-----------+---------------+

      +--------------------------------------------+
      |                  School                    |
      +-----------+------------+---------+---------+
      | School id | Name       | Address | Type    |
      +-----------+------------+---------+---------+
      | 2         | Joe        | Street  | Primary |
      +-----------+------------+---------+---------+

      +-------------------------+
      |    Student to School    |
      +------------+------------+
      | Student id | School id  |
      +------------+------------+
      | 1          | 2          |
      +------------+------------+

section.center
  h2 Normalization and denormalization

section.center
  h2 Normal forms
  p <a href="http://edn.embarcadero.com/article/25209">Described here</a>

section.center
  h2 Indexes

section.center
  h2 Transactions

section.center
  h2 Structured Query Language
  p is how you communicate with relational databases
<commit_msg>Fill the tables with more data<commit_after>---
layout: lecture
title: Databases
---

section.center data-background="#000"
  h2.white Databases

section.center data-background="#F00"
  h2.white Questions

section.center data-background="#F00"
  h2.white What is a protocol?

section.center data-background="#F00"
  h2.white What are the essentials of HTTP?

section.center data-background="#F00"
  h2.white How can you serve content at a specific URL using Sinatra?

section.center
  h2 The right weapon
  p (relational|object|graph|document) database

section.center
  h2 Relational databases
  p PostgreSQL, MySQL, Microsoft SQL Server, SQLite, ...

section.center data-background="#AED6FF"
  h2.white SQLite

section.center data-background="#000"
  h2.white Databases

section.center
  h2 A home for your data

section.center
  h2 Data structure

section.center
  h2 Kind of like arrays and hashes

section.center
  h2 Much more complex

section.center
  h2 Optimized for storing lots of data

section.center
  h2 Optimized for retrieving lots of data very, very fast

section.center
  h2 Allows building inner connections between parts of the data

section.center
  h2 Give me the thing that does something and is located somewhere along with its neighbours

section.center
  h2 Key components

section.center
  h2 Table (relation)

section.center
  h2 Column (attribute)

section.center
  h2 Row (record)

section.center
  h2 A table packs entities with common attributes

section
  pre
    '
      +------------------------------------------------+
      |               Student                          |
      +------------+-----------+-----+-----------------+
      | First name | Last name | Age | Address         |
      +------------+-----------+-----+-----------------+
      | Joe        | Somebody  | 17  | Allen Street    |
      | Darrel     | Addington | 15  | Bleecker Street |
      | Dwenn      | Charlton  | 18  | Lenox Avenue    |
      +------------+-----------+-----+-----------------+

section.center
  h2 Relating tables

section.center
  h2 primary key -> foreign key

section.center
  pre
    '
      +------------------------------------------------+
      |                    Student                     |
      +------------+-----------+-----+-----------------+
      | First name | Last name | Age | Address         |
      +------------+-----------+-----+-----------------+
      | Joe        | Somebody  | 17  | Allen Street    |
      | Darrel     | Addington | 15  | Bleecker Street |
      | Dwenn      | Charlton  | 18  | Lenox Avenue    |
      +------------+-----------+-----+-----------------+

section.center
  pre
    '
      +-------------------------------------------------------------------+
      |                            Student                                |
      +------------+-----------+-----+-----------------+------------------+
      | First name | Last name | Age | Address         | School name      |
      +------------+-----------+-----+-----------------+------------------+
      | Joe        | Somebody  | 17  | Allen Street    | Southview School |
      | Darrel     | Addington | 15  | Bleecker Street | Westview School  |
      | Dwenn      | Charlton  | 18  | Lenox Avenue    | Southview School |
      +------------+-----------+-----+-----------------+------------------+

section.center
  pre
    '
      +-----------------------------------------------------+
      |                      Student                        |
      +----+------------+-----------+-----+-----------------+
      | id | First name | Last name | Age | Address         |
      +----+------------+-----------+-----+-----------------+
      | 1  | Joe        | Somebody  | 17  | Allen Street    |
      | 2  | Darrel     | Addington | 15  | Bleecker Street |
      | 3  | Dwenn      | Charlton  | 18  | Lenox Avenue    |
      +----+------------+-----------+-----+-----------------+

      +-------------------------------+
      |            School             |
      +------------+------------------+
      | Student id | School name      |
      +------------+------------------+
      | 1          | Southview School |
      | 2          | Westview School  |
      | 3          | Southview School |
      +------------+------------------+

section.center
  pre
    '
      +-----------------------------------------------------+
      |                      Student                        |
      +----+------------+-----------+-----+-----------------+
      | id | First name | Last name | Age | Address         |
      +----+------------+-----------+-----+-----------------+
      | 1  | Joe        | Somebody  | 17  | Allen Street    |
      | 2  | Darrel     | Addington | 15  | Bleecker Street |
      | 3  | Dwenn      | Charlton  | 18  | Lenox Avenue    |
      +----+------------+-----------+-----+-----------------+

      +--------------------------------------------------------------+
      |                           School                             |
      +------------+------------------+------------------+-----------+
      | Student id | School           | Address          | Type      |
      +------------+------------------+------------------+-----------+
      | 1          | Southview School | Ludlow Street    | Secondary |
      | 2          | Westview School  | Rivington Street | Primary   |
      | 3          | Southview School | Ludlow Street    | Secondary |
      +------------+------------------+------------------+-----------+

section.center
  pre
    '
      +-----------------------------------------------------+
      |                      Student                        |
      +----+------------+-----------+-----+-----------------+
      | id | First name | Last name | Age | Address         |
      +----+------------+-----------+-----+-----------------+
      | 1  | Joe        | Somebody  | 17  | Allen Street    |
      | 2  | Darrel     | Addington | 15  | Bleecker Street |
      | 3  | Dwenn      | Charlton  | 18  | Lenox Avenue    |
      +----+------------+-----------+-----+-----------------+

      +------------------------------------------------------+
      |                       School                         |
      +----+------------------+------------------+-----------+
      | id | Name             | Address          | Type      |
      +----+------------------+------------------+-----------+
      | 1  | Southview School | Ludlow Street    | Secondary |
      | 2  | Westview School  | Rivington Street | Primary   |
      +----+------------------+------------------+-----------+

      +-------------------------+
      |    Student to School    |
      +------------+------------+
      | Student id | School id  |
      +------------+------------+
      | 1          | 1          |
      | 2          | 2          |
      | 3          | 1          |
      +------------+------------+

section.center
  h2 Normalization and denormalization

section.center
  h2 Normal forms
  p <a href="http://edn.embarcadero.com/article/25209">Described here</a>

section.center
  h2 Indexes

section.center
  h2 Transactions

section.center
  h2 Structured Query Language
  p is how you communicate with relational databases

{'fraction_non_alphanumeric': 0.34291292463881295, 'fraction_numerical': 0.0139789144865287, 'mean_word_length': 0.7530458590006844, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1018949', 'n_tokens_mistral': 3155, 'n_tokens_neox': 2871, 'n_words': 778}