From d8c66a41a8e68cb1aa31b6a8b05aaeb6109530db Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 11 Feb 2012 12:09:19 -0500 Subject: [PATCH 1/5] Working through Learn SQL The Hard Way since we may be using it in a future course for non-programmers at work. --- .gitignore | 1 + ex1.sql | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 .gitignore create mode 100644 ex1.sql diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..98e6ef6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.db diff --git a/ex1.sql b/ex1.sql new file mode 100644 index 0000000..a11c388 --- /dev/null +++ b/ex1.sql @@ -0,0 +1,6 @@ +CREATE TABLE person ( + id INTEGER PRIMARY KEY, + first_name TEXT, + last_name TEXT, + age INTEGER +); From 02d0a5b41e13e20b8f46cad2f5e786e241b118f8 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 11 Feb 2012 12:49:03 -0500 Subject: [PATCH 2/5] Through ex2 --- ex2.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 ex2.sql diff --git a/ex2.sql b/ex2.sql new file mode 100644 index 0000000..48a85a9 --- /dev/null +++ b/ex2.sql @@ -0,0 +1,19 @@ +CREATE TABLE person ( + id INTEGER PRIMARY KEY, + first_name TEXT, + last_name TEXT, + age INTEGER +); + +CREATE TABLE pet ( + id INTEGER PRIMARY KEY, + name TEXT, + breed TEXT, + age INTEGER, + dead INTEGER +); + +CREATE TABLE person_pet ( + person_id INTEGER, + pet_id INTEGER +); From d7b4f60519b18c4912d9cc5a0da00a7aa8c49904 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 11 Feb 2012 12:58:40 -0500 Subject: [PATCH 3/5] ex3! --- ex3-myself.sql | 14 ++++++++++++++ ex3.sql | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100644 ex3-myself.sql create mode 100644 ex3.sql diff --git a/ex3-myself.sql b/ex3-myself.sql new file mode 100644 index 0000000..abd19c5 --- /dev/null +++ b/ex3-myself.sql @@ -0,0 +1,14 @@ +INSERT INTO person (id, first_name, last_name, age) + VALUES (1, "Dan", "Buch", 31); + +INSERT INTO pet (id, name, breed, age, dead) + VALUES (2, "Franny", "Dog", 14, 0); + +INSERT INTO pet (id, name, breed, age, dead) + VALUES (3, "Zooey", "Cat", 7, 0); + +INSERT INTO person_pet (person_id, pet_id) + VALUES (1, 2); + +INSERT INTO person_pet (person_id, pet_id) + VALUES (1, 3); diff --git a/ex3.sql b/ex3.sql new file mode 100644 index 0000000..0c14ca2 --- /dev/null +++ b/ex3.sql @@ -0,0 +1,7 @@ +INSERT INTO person (id, first_name, last_name, age) + VALUES (0, "Zed", "Shaw", 37); + +INSERT INTO pet (id, name, breed, age, dead) + VALUES (0, "Fluffy", "Unicorn", 1000, 0); + +INSERT INTO pet VALUES (1, "Gigantor", "Robot", 1, 1); From 17a02e5f3ddfa8183dd48bd62509d1bfdac559ab Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 11 Feb 2012 13:02:31 -0500 Subject: [PATCH 4/5] ex4! --- ex3-myself.sql | 6 ------ ex4-myself.sql | 5 +++++ ex4.sql | 2 ++ 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 ex4-myself.sql create mode 100644 ex4.sql diff --git a/ex3-myself.sql b/ex3-myself.sql index abd19c5..391d32f 100644 --- a/ex3-myself.sql +++ b/ex3-myself.sql @@ -6,9 +6,3 @@ INSERT INTO pet (id, name, breed, age, dead) INSERT INTO pet (id, name, breed, age, dead) VALUES (3, "Zooey", "Cat", 7, 0); - -INSERT INTO person_pet (person_id, pet_id) - VALUES (1, 2); - -INSERT INTO person_pet (person_id, pet_id) - VALUES (1, 3); diff --git a/ex4-myself.sql b/ex4-myself.sql new file mode 100644 index 0000000..432b133 --- /dev/null +++ b/ex4-myself.sql @@ -0,0 +1,5 @@ +INSERT INTO person_pet (person_id, pet_id) + VALUES (1, 2); + +INSERT INTO person_pet (person_id, pet_id) + VALUES (1, 3); diff --git a/ex4.sql b/ex4.sql new file mode 100644 index 0000000..5d5eb14 --- /dev/null +++ b/ex4.sql @@ -0,0 +1,2 @@ +INSERT INTO person_pet (person_id, pet_id) VALUES (0, 0); +INSERT INTO person_pet VALUES (0, 1); From 45ac55d14c734fb12e130efc80476325866c4cb7 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 11 Feb 2012 13:05:15 -0500 Subject: [PATCH 5/5] ex5! --- ex5.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 ex5.sql diff --git a/ex5.sql b/ex5.sql new file mode 100644 index 0000000..0839fcf --- /dev/null +++ b/ex5.sql @@ -0,0 +1,7 @@ +SELECT * FROM person; + +SELECT name, age FROM pet; + +SELECT name, age FROM pet WHERE dead = 0; + +SELECT * FROM person WHERE first_name != "Zed";