Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean init.sql #1

Open
wants to merge 1 commit into
base: solved
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 0 additions & 107 deletions postgres/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,110 +95,3 @@ INSERT INTO payments (user_id, amount, description, date) VALUES (2, 20.00, 'Jav

INSERT INTO user_payments (user_id, payment_id) VALUES (2, 1);
INSERT INTO user_payments (user_id, payment_id) VALUES (2, 2);

-- Get users list including user role, payment, and courses data

-- Queries for testing the database
-- SELECT * FROM roles;
-- SELECT * FROM users;
-- SELECT * FROM user_roles;
-- SELECT * FROM profiles;
-- SELECT * FROM courses;
-- SELECT * FROM user_courses;
-- SELECT * FROM payments;
-- SELECT * FROM user_payments;

-- Query for getting the user and role data
-- SELECT users.username, roles.role_name FROM users
-- JOIN user_roles ON users.id = user_roles.user_id
-- JOIN roles ON user_roles.role_id = roles.id;

-- Query for getting the user and course data
-- SELECT users.username, courses.course_name FROM users
-- JOIN user_courses ON users.id = user_courses.user_id
-- JOIN courses ON user_courses.course_id = courses.id;

-- Query for getting the user and payment data
-- SELECT users.username, payments.amount FROM users
-- JOIN user_payments ON users.id = user_payments.user_id
-- JOIN payments ON user_payments.payment_id = payments.id;

-- Query for getting the profile data
-- SELECT users.username, profiles.first_name, profiles.last_name, profiles.email, profiles.phone FROM users
-- JOIN profiles ON users.id = profiles.user_id;

-- Query for getting the user, role, course, and payment data
-- SELECT users.username, roles.role_name, courses.course_name, payments.amount FROM users
-- JOIN user_roles ON users.id = user_roles.user_id
-- JOIN roles ON user_roles.role_id = roles.id
-- JOIN user_courses ON users.id = user_courses.user_id
-- JOIN courses ON user_courses.course_id = courses.id
-- JOIN user_payments ON users.id = user_payments.user_id
-- JOIN payments ON user_payments.payment_id = payments.id
-- JOIN profiles ON users.id = profiles.user_id;

-- Query for inserting a new user
-- INSERT INTO users (username, password) VALUES ('user1', 'user1');

-- Query for inserting a new profile
-- INSERT INTO profiles (user_id, first_name, last_name, email, phone) VALUES (3, 'User', 'User', '[email protected]', '1234567890');

-- Query for inserting a new role
-- INSERT INTO roles (role_name) VALUES ('user');

-- Query for inserting a new user role
-- INSERT INTO user_roles (user_id, role_id) VALUES (3, 2);

-- Query for inserting a new course
-- INSERT INTO courses (course_name) VALUES ('Course 4');

-- Query for inserting a new user course
-- INSERT INTO user_courses (user_id, course_id) VALUES (3, 4);

-- Query for inserting a new payment
-- INSERT INTO payments (user_id, amount) VALUES (3, 300.00);

-- Query for inserting a new user payment
-- INSERT INTO user_payments (user_id, payment_id) VALUES (3, 3);

-- Query for create and relate a new payment to an existing user at the same time
-- INSERT INTO payments (user_id, amount) VALUES ((SELECT id FROM users WHERE username = 'user1'), 300.00);

-- Query for updating a user
-- UPDATE users SET username = 'user2' WHERE id = 3;

-- Query for updating a profile
-- UPDATE profiles SET first_name = 'User2' WHERE user_id = 3;

-- Query for updating a role
-- UPDATE roles SET role_name = 'admin' WHERE id = 3;

-- Query for updating a course
-- UPDATE courses SET course_name = 'Course 5' WHERE id = 4;

-- Query for updating a payment
-- UPDATE payments SET amount = 400.00 WHERE id = 3;

-- Query for deleting a user
-- DELETE FROM users WHERE id = 3;

-- Query for deleting a profile
-- DELETE FROM profiles WHERE user_id = 3;

-- Query for deleting a role
-- DELETE FROM roles WHERE id = 3;

-- Query for deleting a course
-- DELETE FROM courses WHERE id = 4;

-- Query for deleting a payment
-- DELETE FROM payments WHERE id = 3;

-- Query for deleting a user role
-- DELETE FROM user_roles WHERE user_id = 3;

-- Query for deleting a user course
-- DELETE FROM user_courses WHERE user_id = 3;

-- Query for deleting a user payment
-- DELETE FROM user_payments WHERE user_id = 3;