R
@rusnayusef
Challenge: Clothing alterations
CREATE TABLE clothes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
type TEXT,
design TEXT);
INSERT INTO clothes (type, design)
VALUES ("dress", "pink polka dots");
INSERT INTO clothes (type, design)
VALUES ("pants", "rainbow tie-dye");
INSERT INTO clothes (type, design)
Challenge: Dynamic Documents
CREATE table documents (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT,
content TEXT,
author TEXT);
INSERT INTO documents (author, title, content)
VALUES ("Puff T.M. Dragon", "Fancy Stuff", "Ceiling wax, dragon wings, etc.");
INSERT INTO documents (author, title, content)
VALUES ("Puff T.M. Dragon", "Living Things", "They're located in the left ear, you know.");
Project: Famous people
CREATE TABLE Actors (
id INTEGER PRIMARY KEY AUTOINCREMENT,
fullname TEXT,
age INTEGER,
nationality TEXT);
INSERT INTO Actors (fullname, age, nationality) VALUES ("Tom Cruise", 60, "US");
INSERT INTO Actors (fullname, age, nationality) VALUES ("Chris Hemsworth", 38, "Australia");
INSERT INTO Actors (fullname, age, nationality) VALUES ("Will Smith", 53, "US");
INSERT INTO Actors (fullname, age, nationality) VALUES ("Jennifer Lopez", 53, "US");
Challenge: FriendBook
CREATE TABLE persons (
id INTEGER PRIMARY KEY AUTOINCREMENT,
fullname TEXT,
age INTEGER);
INSERT INTO persons (fullname, age) VALUES ("Bobby McBobbyFace", "12");
INSERT INTO persons (fullname, age) VALUES ("Lucy BoBucie", "25");
INSERT INTO persons (fullname, age) VALUES ("Banana FoFanna", "14");
INSERT INTO persons (fullname, age) VALUES ("Shish Kabob", "20");
INSERT INTO persons (fullname, age) VALUES ("Fluffy Sparkles", "8");
Sequels in SQL
CREATE TABLE movies (id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT,
released INTEGER,
sequel_id INTEGER);
INSERT INTO movies
VALUES (1, "Harry Potter and the Philosopher's Stone", 2001, 2);
INSERT INTO movies
VALUES (2, "Harry Potter and the Chamber of Secrets", 2002, 3);
INSERT INTO movies
Challenge: Customer's orders
CREATE TABLE customers (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
email TEXT);
INSERT INTO customers (name, email) VALUES ("Doctor Who", "doctorwho@timelords.com");
INSERT INTO customers (name, email) VALUES ("Harry Potter", "harry@potter.com");
INSERT INTO customers (name, email) VALUES ("Captain Awesome", "captain@awesome.com");
CREATE TABLE orders (
Challenge: Bobby's Hobbies
CREATE TABLE persons (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
age INTEGER);
INSERT INTO persons (name, age) VALUES ("Bobby McBobbyFace", 12);
INSERT INTO persons (name, age) VALUES ("Lucy BoBucie", 25);
INSERT INTO persons (name, age) VALUES ("Banana FoFanna", 14);
INSERT INTO persons (name, age) VALUES ("Shish Kabob", 20);
INSERT INTO persons (name, age) VALUES ("Fluffy Sparkles", 8);
Project: Data dig
CREATE TABLE sales(
ID INTEGER NOT NULL PRIMARY KEY
, transaction_date TEXT
, product TEXT
, price INTEGER
, payment_type TEXT
, name TEXT
, city TEXT
, state TEXT
, country TEXT
Challenge: Gradebook
CREATE TABLE student_grades (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
number_grade INTEGER,
fraction_completed REAL);
INSERT INTO student_grades (name, number_grade, fraction_completed)
VALUES ("Winston", 90, 0.805);
INSERT INTO student_grades (name, number_grade, fraction_completed)
VALUES ("Winnefer", 95, 0.901);
Challenge: The wordiest author
CREATE TABLE books (
id INTEGER PRIMARY KEY AUTOINCREMENT,
author TEXT,
title TEXT,
words INTEGER);
INSERT INTO books (author, title, words)
VALUES ("J.K. Rowling", "Harry Potter and the Philosopher's Stone", 79944);
INSERT INTO books (author, title, words)
VALUES ("J.K. Rowling", "Harry Potter and the Chamber of Secrets", 85141);
Challenge: Playlist maker
CREATE TABLE artists (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
country TEXT,
genre TEXT);
INSERT INTO artists (name, country, genre)
VALUES ("Taylor Swift", "US", "Pop");
INSERT INTO artists (name, country, genre)
VALUES ("Led Zeppelin", "US", "Hard rock");
Challenge: Karaoke song selector
CREATE TABLE songs (
id INTEGER PRIMARY KEY,
title TEXT,
artist TEXT,
mood TEXT,
duration INTEGER,
released INTEGER);
INSERT INTO songs (title, artist, mood, duration, released)
VALUES ("Bohemian Rhapsody", "Queen", "epic", 60, 1975);
Project: Design a store database (FROSTY)
create table FROSTY(id integer primary key, BRAND text, FLAVOUR text, QUANTITY integer, PRICE integer);
insert into FROSTY values(1, "BR", "Chocolate", 5, 12);
insert into FROSTY values(2, "BR", "Vanilla", 10, 11);
insert into FROSTY values(3, "BR", "Strawberry", 13, 12);
insert into FROSTY values(4, "BR", "Pistaccio", 5, 14);
insert into FROSTY values(5, "KWALITY", "Mango", 8, 4);
insert into FROSTY values(6, "KWALITY", "Orange", 3, 4);
insert into FROSTY values(7, "KWALITY", "Chocolate",
Challenge: TODO list database stats
CREATE TABLE todo_list (id INTEGER PRIMARY KEY, item TEXT, minutes INTEGER);
INSERT INTO todo_list VALUES (1, "Wash the dishes", 15);
INSERT INTO todo_list VALUES (2, "vacuuming", 20);
INSERT INTO todo_list VALUES (3, "Learn some stuff on KA", 30);
INSERT INTO todo_list VALUES (4, "workout", 40);
SELECT SUM(minutes) FROM todo_list;
Challenge: Box office hits database
CREATE TABLE movies (id INTEGER PRIMARY KEY, name TEXT, release_year INTEGER);
INSERT INTO movies VALUES (1, "Avatar", 2009);
INSERT INTO movies VALUES (2, "Titanic", 1997);
INSERT INTO movies VALUES (3, "Star Wars: Episode IV - A New Hope", 1977);
INSERT INTO movies VALUES (4, "Shrek 2", 2004);
INSERT INTO movies VALUES (5, "The Lion King", 1994);
INSERT INTO movies VALUES (6, "Disney's Up", 2009);
SELECT * FROM movies;
SELECT * FROM movies WHERE release_year > 2000 ORDER BY release_year;
Book list database
/** Books list:
Divergent (5)
The Hunger games (5)
The Clock work angel (6)
**/
CREATE TABLE books (id INTEGER PRIMARY KEY, name TEXT, ratings INTEGER);
INSERT INTO books VALUES (1, "Divergent", 5);
INSERT INTO books VALUES (2, "The Hunger games", 5);
INSERT INTO books VALUES (3, "The Clock work Angel", 6);