Skip to content

Commit

Permalink
add more examples from courses
Browse files Browse the repository at this point in the history
  • Loading branch information
fey committed Apr 4, 2024
1 parent 3a89df6 commit 11f4a38
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 0 deletions.
6 changes: 6 additions & 0 deletions authors.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
INSERT INTO authors (author_id, author_name, origin) VALUES
(1, 'Alexander Pushkin', 'Russia'),
(2, 'Mark Twain', 'USA'),
(3, 'Jules Verne', 'France'),
(4, 'Л.Н. Толстой', 'Russia'),
(5, 'А.П. Чехов', 'Russia');
9 changes: 9 additions & 0 deletions books.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
INSERT INTO books (book_id, author_id, title, language, genre, age_rating, users_score) VALUES
(1, 1, 'Евгений Онегин', 'Russian', 'Роман', '16+', 4.5),
(2, 1, 'Eugene Onegin', 'English', 'Роман', '16+', 4.6),
(3, 2, 'Приключения Тома Соера', 'Russian', 'Повесть', '0+', 4.0),
(4, 2, 'The Adventures of Tom Sawyer', 'English', 'Повесть', '0+', 4.2),
(5, 3, 'Вокруг света за восемьдесят дней', 'Russian', 'Роман', '12+', 4.5),
(6, 3, 'Le tour du monde en quatre-vingts jours', 'French', 'Роман', '12+', 5.0),
(7, 4, 'Анна Каренина', 'Роман', 'Russian', '18+', 4.7),
(8, 5, 'Война и мир', 'Russian', 'Исторический роман', '12+', 4.3);
6 changes: 6 additions & 0 deletions departments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
INSERT INTO departments (department_id, name) VALUES
(1, 'Development Department'),
(2, 'Marketing Department'),
(3, 'Finance Department'),
(4, 'HR Department'),
(5, 'Sales Department');
14 changes: 14 additions & 0 deletions drivers_passengers_rides.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
INSERT INTO drivers (driver_id, driver_name, phone) VALUES
(1, 'Иванов А.Б.', '+71112223344'),
(2, 'Петрова В.Г.', '+71113334455');

INSERT INTO passengers (passenger_id, passenger_name, phone) VALUES
(101, 'Орлов Д.Е.', '+72229998877'),
(102, 'Соколова Ж.З.', '+72228889900'),
(103, 'Ястребов И.К.', '+73339995566');

INSERT INTO rides (rideid, driver_id, passenger_id, price) VALUES
(1001, 1, 101, 567),
(1002, 1, 102, 234),
(1003, 2, 103, 1234),
(1004, 2, 103, 765);
7 changes: 7 additions & 0 deletions employees.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
INSERT INTO employees (employee_id, department_id, name, salary, position, manager_id) VALUES
(1, 1, 'John Smith', 50000, 'Programmer', 2),
(2, 1, 'Peter Johnson',60000, 'Head of development department', 4),
(3, 2, 'Mary Brown', 55000, 'Programmer', 2),
(4, 2, 'Alex Miller', 70000, 'Technical Director', NULL),
(5, 3, 'Helen White', 48000, 'Head of testing department', 4),
(6, NULL, 'Adam Smith', 10000, 'Tester', 5);
8 changes: 8 additions & 0 deletions materials_and_colors.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
INSERT INTO materials (material_id, material_name) VALUES
(100, 'хлопок'),
(101, 'лен'),
(102, 'шерсть');

INSERT INTO colors (color_id, color_name) VALUES
(0, 'красный'),
(1, 'синий');
9 changes: 9 additions & 0 deletions orders_and_customers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
INSERT INTO customers (customer_id, customer_name, email) VALUES
(1, 'Иванов А.Б.', 'ivanov@email.com'),
(2, 'Петрова В.Г.', 'petrova@email.com'),
(3, 'Сидоров Ж.З.', 's_idorov@email.com');

INSERT INTO orders (order_id, customer_id, total_price) VALUES
(1000, 1, 100),
(1001, 1, 500),
(1002, 3, 300);
77 changes: 77 additions & 0 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,80 @@ CREATE TABLE course_reviews (
body text,
created_at timestamp
);

CREATE TABLE colors (
color_id INT PRIMARY KEY,
color_name VARCHAR(50)
);

CREATE TABLE materials (
material_id INT PRIMARY KEY,
material_name VARCHAR(50)
);

CREATE TABLE authors (
author_id INT PRIMARY KEY,
author_name VARCHAR(50),
origin VARCHAR(50)
);

CREATE TABLE books (
book_id INT PRIMARY KEY,
author_id INT,
title VARCHAR(100),
language VARCHAR(50),
genre VARCHAR(50),
age_rating VARCHAR(5),
users_score DECIMAL(3, 1)
);

CREATE TABLE departments (
department_id INT PRIMARY KEY,
name VARCHAR(50)
);


CREATE TABLE employees (
employee_id INT PRIMARY KEY,
department_id INT,
name VARCHAR(50),
salary DECIMAL(10, 2)
);

CREATE TABLE drivers (
driver_id INT PRIMARY KEY,
driver_name VARCHAR(50),
phone VARCHAR(15)
);

CREATE TABLE passengers (
passenger_id INT PRIMARY KEY,
passenger_name VARCHAR(50),
phone VARCHAR(15)
);

CREATE TABLE rides (
rideid INT PRIMARY KEY,
driver_id INT,
passenger_id INT,
price DECIMAL(10, 2),
FOREIGN KEY (driver_id) REFERENCES drivers(driver_id),
FOREIGN KEY (passenger_id) REFERENCES passengers(passenger_id)
);

CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(50),
email VARCHAR(50)
);

CREATE TABLE orders (
order_id INT PRIMARY KEY,
customer_id INT,
total_price DECIMAL(10, 2)
);

CREATE TABLE employees_with_managers (
employee_id INT PRIMARY KEY,
employee_name VARCHAR,
);

0 comments on commit 11f4a38

Please sign in to comment.