Skip to content

Instantly share code, notes, and snippets.

@Samuyi
Last active January 7, 2019 12:20
Show Gist options
  • Save Samuyi/44300a075be322db8fb8e96d72da649d to your computer and use it in GitHub Desktop.
Save Samuyi/44300a075be322db8fb8e96d72da649d to your computer and use it in GitHub Desktop.
tables for a tutorial
CREATE TABLE staff (
staff_id serial primary key,
name text,
salary int,
created_at timestamp with time zone default now()
);
CREATE TABLE cars(
car_id serial primary key,
brand text,
price int,
model text,
sales_bonus int,
created_at timestamp with time zone default now()
);
CREATE TABLE sales(
sales_id serial primary key,
staff_id int references staff,
car_id int references cars,
staff_bonus int,
sales_price int,
created_at timestamp with time zone default now()
);
CREATE TABLE sales_summary(
id serial primary key,
staff_id int references staff,
bonus int,
total_sales int,
created_at timestamp with time zone default current_timestamp
);
INSERT INTO staff (name, salary) VALUES
('Harry Kane', 9000),
('Paul Oshea', 7000),
('Theodore Afleck', 10000);
('Tina Fey', 11000);
('Cynthia Simpson', 8000);
('Amy Fox',10000)
INSERT INTO cars (brand, price, model, sales_bonus) VALUES
('Toyota', 19500, 'camry', 15),
('Ford', 25000, 'mustang', 10),
('Honda', 15000, 'accord', 12),
('Lexus', 45000, 'Lexus NS', 9);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment