Skip to content

Instantly share code, notes, and snippets.

@danielmoralesp
Last active June 22, 2019 17:17
Show Gist options
  • Save danielmoralesp/7c79d373534011504adf5bd0180df418 to your computer and use it in GitHub Desktop.
Save danielmoralesp/7c79d373534011504adf5bd0180df418 to your computer and use it in GitHub Desktop.
Mutiple Tables
CREATE TABLE orders (
  order_id INTEGER,
  customer_id INTEGER,
  subscription_id INTEGER,
  purchase_date TEXT
);


CREATE TABLE subscriptions (
  subscription_id INTEGER,
  description TEXT,
  price_per_month INTEGER,
  subscription_length TEXT
);


CREATE TABLE customers (
  customer_id INTEGER,
  customer_name TEXT,
  address TEXT
);
INSERT INTO orders (order_id, customer_id, subscription_id, purchase_date)
VALUES
(1,	3,	2,	'01-10-2017'),
(2,	2,	4,	'01-09-2017'),
(3,	3,	4,	'01-26-2017'),
(4,	9,	9,	'01-04-2017'),
(5,	7,	5,	'01-25-2017'),
(6,	8,	2,	'01-18-2017'),
(7,	5,	8,	'01-11-2017'),
(8,	9,	5,	'01-26-2017'),
(9,	4,	4,	'01-25-2017'),
(10,	1,	7,	'01-26-2017'),
(11,	5,	4,	'01-07-2017'),
(12,	3,	2,	'01-21-2017'),
(13,	3,	5,	'01-03-2017'),
(14,	6,	5,	'01-22-2017'),
(15,	1,	2,	'01-06-2017'),
(16,	1,	2,	'01-11-2017'),
(17,	3,	6,	'01-17-2017'),
(18,	3,	8,	'01-29-2017'),
(19,	4,	9,	'01-03-2017'),
(20,	1,	7,	'01-24-2017');
INSERT INTO subscriptions (subscription_id, description, price_per_month, subscription_length)
VALUES		
(1,	'Politics Magazine',	10,	'12 months'),
(2,	'Politics Magazine',	11,	'6 months'),
(3,	'Politics Magazine',	12,	'3 months'),
(4,	'Fashion Magazine',	15,	'12 months'),
(5,	'Fashion Magazine',	17,	'6 months'),
(6,	'Fashion Magazine',	19,	'3 months'),
(7,	'Sports Magazine',	11,	'12 months'),
(8,	'Sports Magazine',	12,	'6 months'),
(9,	'Sports Magazine',	13,	'3 months');
INSERT INTO customers (customer_id, customer_name, address)
VALUES	
(1,	'Allie Rahaim',	'123 Broadway'),
(2,	'Jacquline Diddle',	'456 Park Ave.'),
(3,	'Lizabeth Letsche',	'789 Main St.'),
(4,	'Jessia Butman',	'1 Columbus Ave.'),
(5,	'Inocencia Goyco',	'12 Amsterdam Ave.'),
(6,	'Bethann Schraub',	'29 Monticello'),
(7,	'Janay Priolo',	'81 Harrisburg'),
(8,	'Ophelia Sturdnant',	'31 Deerfield Ave.'),
(9,	'Eryn Vilar',	'56 Morton St.'),
(10,	'Jina Farraj',	'100 Bryan Ave.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment