diff --git a/db/01-create-tables.sql b/db/01-create-tables.sql deleted file mode 100644 index 4aa0de5..0000000 --- a/db/01-create-tables.sql +++ /dev/null @@ -1,7 +0,0 @@ - -CREATE TABLE IF NOT EXISTS public.posts -( - id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), - title text COLLATE pg_catalog."default" NOT NULL, - CONSTRAINT "Table 0_pkey" PRIMARY KEY (id) -) \ No newline at end of file diff --git a/db/01-dynamic_web_app.sql b/db/01-dynamic_web_app.sql new file mode 100644 index 0000000..4a8532c --- /dev/null +++ b/db/01-dynamic_web_app.sql @@ -0,0 +1,28 @@ +CREATE SCHEMA IF NOT EXISTS dynamic_web_app; + +CREATE TABLE IF NOT EXISTS dynamic_web_app.posts +( + id SERIAL NOT NULL PRIMARY KEY, + title text NOT NULL +); + +INSERT INTO dynamic_web_app.posts (title) VALUES +('10 Essential PHP Tricks Every Coder Should Know'), +('The Future of PHP: What to Expect in Version 9.0'), +('How to Handle Strings in PHP Like a Pro'), +('Debugging PHP Code: A Step-by-Step Guide'), +('Best Practices for Writing Secure PHP Code'), +('Understanding PHP Functions: A Beginner''s Guide'), +('Optimizing PHP Code for Better Performance'), +('Exploring PHP 8.0: New Features and Improvements'), +('Building a REST API with PHP: A Complete Tutorial'), +('Working with PHP and MySQL: A Guide for Beginners'), +('How to Build a Dynamic Website with PHP and HTML'), +('Top 5 PHP Frameworks to Learn in 2024'), +('Advanced PHP Techniques: Pushing Your Skills Further'), +('Handling User Authentication in PHP'), +('Common PHP Mistakes and How to Avoid Them'), +('Introduction to Object-Oriented Programming in PHP'), +('Why PHP is Still Relevant in Modern Web Development'), +('How to Use Composer for PHP Dependency Management'), +('Integrating APIs with PHP: Everything You Need to Know'); diff --git a/db/02-default-data.sql b/db/02-default-data.sql deleted file mode 100644 index 01f06b1..0000000 --- a/db/02-default-data.sql +++ /dev/null @@ -1 +0,0 @@ -COPY public.posts FROM '/docker-entrypoint-initdb.d/posts.csv' DELIMITER ','; \ No newline at end of file diff --git a/db/02-notes.sql b/db/02-notes.sql new file mode 100644 index 0000000..3ec5288 --- /dev/null +++ b/db/02-notes.sql @@ -0,0 +1,97 @@ +CREATE SCHEMA IF NOT EXISTS notes; + +CREATE TABLE IF NOT EXISTS notes.users +( + id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + name text, + email text, + + CONSTRAINT unique_email UNIQUE (email) +); + +CREATE TABLE IF NOT EXISTS notes.notes +( + id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + body text, + user_id integer NOT NULL, + + CONSTRAINT fk_user FOREIGN KEY (user_id) + REFERENCES notes.users(id) + ON DELETE CASCADE + ON UPDATE CASCADE +); + +INSERT INTO notes.users (name, email) VALUES +('Alice Johnson', 'alice.johnson@example.com'), +('Bob Smith', 'bob.smith@example.com'), +('Charlie Brown', 'charlie.brown@example.com'), +('Dana White', 'dana.white@example.com'), +('Eve Black', 'eve.black@example.com'), +('Frank Green', 'frank.green@example.com'), +('Grace Lee', 'grace.lee@example.com'), +('Hannah King', 'hannah.king@example.com'), +('Ian Scott', 'ian.scott@example.com'), +('Judy Adams', 'judy.adams@example.com'); + + +INSERT INTO notes.notes (body, user_id) VALUES +-- Notes for Alice +('Meeting with the team at 10 AM tomorrow.', 1), +('Remember to send the report to the client by EOD.', 1), +('Don’t forget to review the new project proposal.', 1), +('Plan the agenda for next week’s marketing meeting.', 1), + +-- Notes for Bob +('Call John about the server issues.', 2), +('Update the documentation for the API changes.', 2), +('Submit the budget forecast for Q4.', 2), +('Prepare the presentation slides for the quarterly review.', 2), + +-- Notes for Charlie +('Check the inventory levels for the new product launch.', 3), +('Send the invoice to the supplier.', 3), +('Schedule a follow-up meeting with the design team.', 3), +('Review the feedback from the recent customer survey.', 3), + +-- Notes for Dana +('Draft the email for the new product announcement.', 4), +('Confirm the venue booking for the upcoming event.', 4), +('Coordinate with the PR team for the press release.', 4), +('Update the project timeline with the new deadlines.', 4), + +-- Notes for Eve +('Create a marketing plan for the holiday season.', 5), +('Review the latest analytics report.', 5), +('Organize a team-building activity for next month.', 5), +('Check the status of the ongoing advertising campaign.', 5), + +-- Notes for Frank +('Finalize the design for the new website layout.', 6), +('Schedule a demo of the new software feature.', 6), +('Prepare the user guide for the updated application.', 6), +('Follow up with the development team on the bug fixes.', 6), + +-- Notes for Grace +('Review the proposals for the upcoming project.', 7), +('Send out the invitations for the stakeholder meeting.', 7), +('Update the risk assessment report.', 7), +('Plan the next phase of the project implementation.', 7), + +-- Notes for Hannah +('Prepare the budget report for the next board meeting.', 8), +('Organize a training session for the new employees.', 8), +('Check the progress of the current marketing initiatives.', 8), +('Coordinate with the design team on the new campaign materials.', 8), + +-- Notes for Ian +('Update the customer feedback database.', 9), +('Review and approve the latest product prototypes.', 9), +('Send the quarterly sales report to the finance department.', 9), +('Plan the logistics for the upcoming trade show.', 9), + +-- Notes for Judy +('Draft the proposal for the new client.', 10), +('Schedule a project review meeting with the team.', 10), +('Follow up on the contract negotiations with the vendor.', 10), +('Organize the team’s monthly performance review.', 10); + diff --git a/db/posts.csv b/db/posts.csv deleted file mode 100644 index 3172769..0000000 --- a/db/posts.csv +++ /dev/null @@ -1,19 +0,0 @@ -2,10 Essential PHP Tricks Every Coder Should Know -3,The Future of PHP: What to Expect in Version 9.0 -4,How to Handle Strings in PHP Like a Pro -5,Debugging PHP Code: A Step-by-Step Guide -6,Best Practices for Writing Secure PHP Code -7,Understanding PHP Functions: A Beginner's Guide -8,Optimizing PHP Code for Better Performance -9,Exploring PHP 8.0: New Features and Improvements -10,Building a REST API with PHP: A Complete Tutorial -11,Working with PHP and MySQL: A Guide for Beginners -12,How to Build a Dynamic Website with PHP and HTML -13,Top 5 PHP Frameworks to Learn in 2024 -14,Advanced PHP Techniques: Pushing Your Skills Further -15,Handling User Authentication in PHP -16,Common PHP Mistakes and How to Avoid Them -17,Introduction to Object-Oriented Programming in PHP -18,Why PHP is Still Relevant in Modern Web Development -19,How to Use Composer for PHP Dependency Management -20,Integrating APIs with PHP: Everything You Need to Know diff --git a/www/dynamic_web_app/Database.php b/www/dynamic_web_app/Database.php index 08f6bc5..fe676ad 100644 --- a/www/dynamic_web_app/Database.php +++ b/www/dynamic_web_app/Database.php @@ -12,6 +12,7 @@ class Database $this->pdo = new PDO($dsn, options: [ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ]); + $this->pdo->exec("SET search_path TO dynamic_web_app"); }