Ruby Monstas Session 28 Agenda Introduction to databases, Part 1 - - PowerPoint PPT Presentation

ruby monstas
SMART_READER_LITE
LIVE PREVIEW

Ruby Monstas Session 28 Agenda Introduction to databases, Part 1 - - PowerPoint PPT Presentation

Ruby Monstas Session 28 Agenda Introduction to databases, Part 1 Exercises Introduction to databases Part 1 CSV Recap users.csv first_name,last_name,city,shoe_size Tatjana,Abt,Bern,42 Kasimir,Spitznogle,Luzern,46


slide-1
SLIDE 1

Ruby Monstas

Session 28

slide-2
SLIDE 2

Agenda

Introduction to databases, Part 1 Exercises

slide-3
SLIDE 3

Introduction to databases

Part 1

slide-4
SLIDE 4

CSV Recap

first_name,last_name,city,shoe_size Tatjana,Abt,Bern,42 Kasimir,Spitznogle,Luzern,46 Niklas,Laberenz,Zürich,42 Konstanze,Gotti,Zürich,43 Romy,Ebner,Bern,38 users.csv

slide-5
SLIDE 5

CSV Recap

first_name last_name city shoe_size Tatjana Abt Bern 42 Kasimir Spitznogle Luzern 46 Niklas Laberenz Zürich 42 Konstanze Gotti Zürich 43 Romy Ebner Bern 38

users.csv table row column

slide-6
SLIDE 6

Enter SQLite!

SQL: Structured Query Language SQLite: One implementation of SQL Many other implementations are available: MySQL, PostgreSQL, Microsoft SQL Server, ...

slide-7
SLIDE 7

Creating a table

Create a new table called “users” which has the following columns: first_name (string), last_name (string), city (string), shoe_size (integer)!

CREATE TABLE 'users' (first_name string, last_name string, city string, shoe_size integer);

slide-8
SLIDE 8

Inserting data into a table

Insert a new row into the table “users” with these values: “Tatjana”, “Abt”, “Bern”, 42.

INSERT INTO 'users' VALUES ('Tatjana', 'Abt', 'Bern', 42);

slide-9
SLIDE 9

Some more data...

INSERT INTO 'users' VALUES ('Kasimir', 'Spitznogle', 'Luzern', 46); INSERT INTO 'users' VALUES ('Niklas', 'Laberenz', 'Zürich', 42); INSERT INTO 'users' VALUES ('Konstanze', 'Gotti', 'Zürich', 43); INSERT INTO 'users' VALUES ('Romy', 'Ebner', 'Bern', 38);

slide-10
SLIDE 10

Give me the first name and the last name of all the rows from the table user, where the city is “Bern”!

SELECT first_name, last_name FROM users WHERE city == 'Bern';

Who are our users from Bern?

slide-11
SLIDE 11

What’s the biggest shoe size?

Give me the maximum value of the column shoe_size from the table user!

SELECT max(shoe_size) FROM users;

slide-12
SLIDE 12

Other weird queries

Give me the values of the column city from the table users whose first_name starts with a “K”!

SELECT city FROM users WHERE first_name LIKE 'K%';

Give me the values of the column shoe_size from the table users whose first_name or last_name contain a “z”!

SELECT shoe_size FROM users WHERE first_name LIKE '%z%' OR last_name LIKE '%z%';

slide-13
SLIDE 13

Your feedback, please?

http://goo.gl/forms/rUrZqOPNq6 (Session 27)

slide-14
SLIDE 14

Time to practice