From 164842b824d5cd4db9a4b81e3e3d632e58e7a43f Mon Sep 17 00:00:00 2001 From: scott Date: Wed, 6 Mar 2024 19:00:48 -0500 Subject: [PATCH 1/7] first commit, made table and wrote docs --- .../bookstore-sample-app/db/README.md | 31 +++++++++++++++++++ .../bookstore-sample-app/db/sample.sql | 18 +++++++++++ 2 files changed, 49 insertions(+) create mode 100644 code-samples/eventing/bookstore-sample-app/db/README.md create mode 100644 code-samples/eventing/bookstore-sample-app/db/sample.sql diff --git a/code-samples/eventing/bookstore-sample-app/db/README.md b/code-samples/eventing/bookstore-sample-app/db/README.md new file mode 100644 index 0000000000..0305178cdc --- /dev/null +++ b/code-samples/eventing/bookstore-sample-app/db/README.md @@ -0,0 +1,31 @@ +# Bookstore Database + +1. Database Schema +2. Sample Data + +## 1. Database Schema + +### BookReviews Table +The BookReviews table contains all reviews made on the bookstore website. + +See the columns of the BookReviews table below: +* ID (serial) - Primary Key +* post_time (datetime) - Posting time of the comment +* content (text) - The contents of the comment +* sentiment (text) - The sentiment results (currently, the values it could take on are 'positive' or 'neutral' or 'negative') +* book_id (serial) - Foreign Key, since each comment is associated with a specific book + +## 2. Sample Data + +### BookReviews Table +The sample rows inserted for the BookReviews table are shown below: +| id | post_time | content | sentiment | book_id | +|----|---------------------|------------------------------|-----------|---------| +| 1 | 2020-01-01 00:00:00 | This book is great! | positive | 100 | +| 2 | 2020-01-02 00:02:00 | This book is terrible! | negative | 2 | +| 3 | 2020-01-03 00:01:30 | This book is okay. | neutral | 3 | +| 4 | 2020-01-04 00:00:00 | Meh | neutral | 45 | +| 5 | 2020-01-04 00:04:00 | I HATE THIS BOOK! | negative | 77 | +| 6 | 2020-01-06 00:00:00 | Best thing I have ever read! | positive | 100 | +| 7 | 2020-01-07 00:12:00 | ABSOLUTELY LOVELY! | positive | 50 | +| 8 | 2020-01-08 00:00:00 | Most boring book I picked up | negative | 42 | \ No newline at end of file diff --git a/code-samples/eventing/bookstore-sample-app/db/sample.sql b/code-samples/eventing/bookstore-sample-app/db/sample.sql new file mode 100644 index 0000000000..f6810d711c --- /dev/null +++ b/code-samples/eventing/bookstore-sample-app/db/sample.sql @@ -0,0 +1,18 @@ +CREATE TABLE BookReviews( + id SERIAL PRIMARY KEY, + post_time datetime NOT NULL, + content TEXT NOT NULL, + sentiment TEXT, + CONSTRAINT sentiment_check CHECK (sentiment IN ('positive', 'negative', 'neutral')), + book_id SERIAL NOT NULL, + +); + +INSERT INTO BookReviews VALUES(1, '2020-01-01 00:00:00', 'This book is great!', 'positive', 100); +INSERT INTO BookReviews VALUES(2, '2020-01-02 00:02:00', 'This book is terrible!', 'negative', 2); +INSERT INTO BookReviews VALUES(3, '2020-01-03 00:01:30', 'This book is okay.', 'neutral', 3); +INSERT INTO BookReviews VALUES(4, '2020-01-04 00:00:00', 'Meh', 'neutral', 45); +INSERT INTO BookReviews VALUES(5, '2020-01-04 00:04:00', 'I HATE THIS BOOK!', 'negative', 77); +INSERT INTO BookReviews VALUES(6, '2020-01-06 00:00:00', 'Best thing I have ever read!', 'positive', 100); +INSERT INTO BookReviews VALUES(7, '2020-01-07 00:12:00', 'ABSOLUTELY LOVELY!', 'positive', 50); +INSERT INTO BookReviews VALUES(8, '2020-01-08 00:00:00', 'Most boring book I picked up', 'negative', 42); \ No newline at end of file From 7d41175fa7579ead6811fd79f6f0a36d35dd07d1 Mon Sep 17 00:00:00 2001 From: scott Date: Thu, 7 Mar 2024 11:42:42 -0500 Subject: [PATCH 2/7] removed book id --- .../bookstore-sample-app/db/README.md | 21 +++++++++---------- .../bookstore-sample-app/db/sample.sql | 18 +++++++--------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/code-samples/eventing/bookstore-sample-app/db/README.md b/code-samples/eventing/bookstore-sample-app/db/README.md index 0305178cdc..ca49f8f5b5 100644 --- a/code-samples/eventing/bookstore-sample-app/db/README.md +++ b/code-samples/eventing/bookstore-sample-app/db/README.md @@ -13,19 +13,18 @@ See the columns of the BookReviews table below: * post_time (datetime) - Posting time of the comment * content (text) - The contents of the comment * sentiment (text) - The sentiment results (currently, the values it could take on are 'positive' or 'neutral' or 'negative') -* book_id (serial) - Foreign Key, since each comment is associated with a specific book ## 2. Sample Data ### BookReviews Table The sample rows inserted for the BookReviews table are shown below: -| id | post_time | content | sentiment | book_id | -|----|---------------------|------------------------------|-----------|---------| -| 1 | 2020-01-01 00:00:00 | This book is great! | positive | 100 | -| 2 | 2020-01-02 00:02:00 | This book is terrible! | negative | 2 | -| 3 | 2020-01-03 00:01:30 | This book is okay. | neutral | 3 | -| 4 | 2020-01-04 00:00:00 | Meh | neutral | 45 | -| 5 | 2020-01-04 00:04:00 | I HATE THIS BOOK! | negative | 77 | -| 6 | 2020-01-06 00:00:00 | Best thing I have ever read! | positive | 100 | -| 7 | 2020-01-07 00:12:00 | ABSOLUTELY LOVELY! | positive | 50 | -| 8 | 2020-01-08 00:00:00 | Most boring book I picked up | negative | 42 | \ No newline at end of file +| id | post_time | content | sentiment | +|----|---------------------|------------------------------|-----------| +| 1 | 2020-01-01 00:00:00 | This book is great! | positive | +| 2 | 2020-01-02 00:02:00 | This book is terrible! | negative | +| 3 | 2020-01-03 00:01:30 | This book is okay. | neutral | +| 4 | 2020-01-04 00:00:00 | Meh | neutral | +| 5 | 2020-01-04 00:04:00 | I HATE THIS BOOK! | negative | +| 6 | 2020-01-06 00:00:00 | Best thing I have ever read! | positive | +| 7 | 2020-01-07 00:12:00 | ABSOLUTELY LOVELY! | positive | +| 8 | 2020-01-08 00:00:00 | Most boring book I picked up | negative | \ No newline at end of file diff --git a/code-samples/eventing/bookstore-sample-app/db/sample.sql b/code-samples/eventing/bookstore-sample-app/db/sample.sql index f6810d711c..4684f19b16 100644 --- a/code-samples/eventing/bookstore-sample-app/db/sample.sql +++ b/code-samples/eventing/bookstore-sample-app/db/sample.sql @@ -4,15 +4,13 @@ CREATE TABLE BookReviews( content TEXT NOT NULL, sentiment TEXT, CONSTRAINT sentiment_check CHECK (sentiment IN ('positive', 'negative', 'neutral')), - book_id SERIAL NOT NULL, - ); -INSERT INTO BookReviews VALUES(1, '2020-01-01 00:00:00', 'This book is great!', 'positive', 100); -INSERT INTO BookReviews VALUES(2, '2020-01-02 00:02:00', 'This book is terrible!', 'negative', 2); -INSERT INTO BookReviews VALUES(3, '2020-01-03 00:01:30', 'This book is okay.', 'neutral', 3); -INSERT INTO BookReviews VALUES(4, '2020-01-04 00:00:00', 'Meh', 'neutral', 45); -INSERT INTO BookReviews VALUES(5, '2020-01-04 00:04:00', 'I HATE THIS BOOK!', 'negative', 77); -INSERT INTO BookReviews VALUES(6, '2020-01-06 00:00:00', 'Best thing I have ever read!', 'positive', 100); -INSERT INTO BookReviews VALUES(7, '2020-01-07 00:12:00', 'ABSOLUTELY LOVELY!', 'positive', 50); -INSERT INTO BookReviews VALUES(8, '2020-01-08 00:00:00', 'Most boring book I picked up', 'negative', 42); \ No newline at end of file +INSERT INTO BookReviews VALUES(1, '2020-01-01 00:00:00', 'This book is great!', 'positive'); +INSERT INTO BookReviews VALUES(2, '2020-01-02 00:02:00', 'This book is terrible!', 'negative'); +INSERT INTO BookReviews VALUES(3, '2020-01-03 00:01:30', 'This book is okay.', 'neutral'); +INSERT INTO BookReviews VALUES(4, '2020-01-04 00:00:00', 'Meh', 'neutral'); +INSERT INTO BookReviews VALUES(5, '2020-01-04 00:04:00', 'I HATE THIS BOOK!', 'negative'); +INSERT INTO BookReviews VALUES(6, '2020-01-06 00:00:00', 'Best thing I have ever read!', 'positive'); +INSERT INTO BookReviews VALUES(7, '2020-01-07 00:12:00', 'ABSOLUTELY LOVELY!', 'positive'); +INSERT INTO BookReviews VALUES(8, '2020-01-08 00:00:00', 'Most boring book I picked up', 'negative'); \ No newline at end of file From 6664228854849f64e7a431e4d6ad26206fe988ab Mon Sep 17 00:00:00 2001 From: scott Date: Thu, 7 Mar 2024 15:50:49 -0500 Subject: [PATCH 3/7] reduced amt of sample data --- code-samples/eventing/bookstore-sample-app/db/README.md | 6 +----- code-samples/eventing/bookstore-sample-app/db/sample.sql | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/code-samples/eventing/bookstore-sample-app/db/README.md b/code-samples/eventing/bookstore-sample-app/db/README.md index ca49f8f5b5..9fb745e878 100644 --- a/code-samples/eventing/bookstore-sample-app/db/README.md +++ b/code-samples/eventing/bookstore-sample-app/db/README.md @@ -23,8 +23,4 @@ The sample rows inserted for the BookReviews table are shown below: | 1 | 2020-01-01 00:00:00 | This book is great! | positive | | 2 | 2020-01-02 00:02:00 | This book is terrible! | negative | | 3 | 2020-01-03 00:01:30 | This book is okay. | neutral | -| 4 | 2020-01-04 00:00:00 | Meh | neutral | -| 5 | 2020-01-04 00:04:00 | I HATE THIS BOOK! | negative | -| 6 | 2020-01-06 00:00:00 | Best thing I have ever read! | positive | -| 7 | 2020-01-07 00:12:00 | ABSOLUTELY LOVELY! | positive | -| 8 | 2020-01-08 00:00:00 | Most boring book I picked up | negative | \ No newline at end of file +| 4 | 2020-01-04 00:00:00 | Meh | neutral | \ No newline at end of file diff --git a/code-samples/eventing/bookstore-sample-app/db/sample.sql b/code-samples/eventing/bookstore-sample-app/db/sample.sql index 4684f19b16..efb7508109 100644 --- a/code-samples/eventing/bookstore-sample-app/db/sample.sql +++ b/code-samples/eventing/bookstore-sample-app/db/sample.sql @@ -9,8 +9,4 @@ CREATE TABLE BookReviews( INSERT INTO BookReviews VALUES(1, '2020-01-01 00:00:00', 'This book is great!', 'positive'); INSERT INTO BookReviews VALUES(2, '2020-01-02 00:02:00', 'This book is terrible!', 'negative'); INSERT INTO BookReviews VALUES(3, '2020-01-03 00:01:30', 'This book is okay.', 'neutral'); -INSERT INTO BookReviews VALUES(4, '2020-01-04 00:00:00', 'Meh', 'neutral'); -INSERT INTO BookReviews VALUES(5, '2020-01-04 00:04:00', 'I HATE THIS BOOK!', 'negative'); -INSERT INTO BookReviews VALUES(6, '2020-01-06 00:00:00', 'Best thing I have ever read!', 'positive'); -INSERT INTO BookReviews VALUES(7, '2020-01-07 00:12:00', 'ABSOLUTELY LOVELY!', 'positive'); -INSERT INTO BookReviews VALUES(8, '2020-01-08 00:00:00', 'Most boring book I picked up', 'negative'); \ No newline at end of file +INSERT INTO BookReviews VALUES(4, '2020-01-04 00:00:00', 'Meh', 'neutral'); \ No newline at end of file From b4c560d31163a372da9bd05bdb66c8cd8eaaff11 Mon Sep 17 00:00:00 2001 From: Scott Hirano <86282459+Zazzscoot@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:13:21 -0500 Subject: [PATCH 4/7] Update code-samples/eventing/bookstore-sample-app/db/sample.sql Co-authored-by: Calum Murray --- code-samples/eventing/bookstore-sample-app/db/sample.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code-samples/eventing/bookstore-sample-app/db/sample.sql b/code-samples/eventing/bookstore-sample-app/db/sample.sql index efb7508109..359e7943b8 100644 --- a/code-samples/eventing/bookstore-sample-app/db/sample.sql +++ b/code-samples/eventing/bookstore-sample-app/db/sample.sql @@ -1,4 +1,5 @@ -CREATE TABLE BookReviews( +CREATE TABLE IF NOT EXISTS book_reviews( + id SERIAL PRIMARY KEY, post_time datetime NOT NULL, content TEXT NOT NULL, From 7ae6c3f741c71b1faec41fd4c38af19c2460efd6 Mon Sep 17 00:00:00 2001 From: Scott Hirano <86282459+Zazzscoot@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:13:33 -0500 Subject: [PATCH 5/7] Update code-samples/eventing/bookstore-sample-app/db/sample.sql Co-authored-by: Calum Murray --- code-samples/eventing/bookstore-sample-app/db/sample.sql | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code-samples/eventing/bookstore-sample-app/db/sample.sql b/code-samples/eventing/bookstore-sample-app/db/sample.sql index 359e7943b8..b70432aa5c 100644 --- a/code-samples/eventing/bookstore-sample-app/db/sample.sql +++ b/code-samples/eventing/bookstore-sample-app/db/sample.sql @@ -7,7 +7,8 @@ CREATE TABLE IF NOT EXISTS book_reviews( CONSTRAINT sentiment_check CHECK (sentiment IN ('positive', 'negative', 'neutral')), ); -INSERT INTO BookReviews VALUES(1, '2020-01-01 00:00:00', 'This book is great!', 'positive'); -INSERT INTO BookReviews VALUES(2, '2020-01-02 00:02:00', 'This book is terrible!', 'negative'); -INSERT INTO BookReviews VALUES(3, '2020-01-03 00:01:30', 'This book is okay.', 'neutral'); -INSERT INTO BookReviews VALUES(4, '2020-01-04 00:00:00', 'Meh', 'neutral'); \ No newline at end of file +INSERT INTO book_reviews (post_time, content, sentiment) VALUES + ('2020-01-01 00:00:00', 'This book is great!', 'positive'), + ('2020-01-02 00:02:00', 'This book is terrible!', 'negative'), + ('2020-01-03 00:01:30', 'This book is okay.', 'neutral'), + ('2020-01-04 00:00:00', 'Meh', 'neutral'); \ No newline at end of file From 847012b6b02a2f5e79bbba0d34820b5e14f7b202 Mon Sep 17 00:00:00 2001 From: Scott Hirano <86282459+Zazzscoot@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:24:00 -0500 Subject: [PATCH 6/7] Update code-samples/eventing/bookstore-sample-app/db/sample.sql Co-authored-by: Calum Murray --- code-samples/eventing/bookstore-sample-app/db/sample.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/code-samples/eventing/bookstore-sample-app/db/sample.sql b/code-samples/eventing/bookstore-sample-app/db/sample.sql index b70432aa5c..fb6152269b 100644 --- a/code-samples/eventing/bookstore-sample-app/db/sample.sql +++ b/code-samples/eventing/bookstore-sample-app/db/sample.sql @@ -1,5 +1,4 @@ CREATE TABLE IF NOT EXISTS book_reviews( - id SERIAL PRIMARY KEY, post_time datetime NOT NULL, content TEXT NOT NULL, From 06e11fef59cca62d457c779a7503f6600930f033 Mon Sep 17 00:00:00 2001 From: Scott Hirano <86282459+Zazzscoot@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:24:18 -0500 Subject: [PATCH 7/7] Update code-samples/eventing/bookstore-sample-app/db/sample.sql Co-authored-by: Calum Murray --- code-samples/eventing/bookstore-sample-app/db/sample.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code-samples/eventing/bookstore-sample-app/db/sample.sql b/code-samples/eventing/bookstore-sample-app/db/sample.sql index fb6152269b..c690b0c7bc 100644 --- a/code-samples/eventing/bookstore-sample-app/db/sample.sql +++ b/code-samples/eventing/bookstore-sample-app/db/sample.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS book_reviews( id SERIAL PRIMARY KEY, - post_time datetime NOT NULL, + post_time timestamp NOT NULL, content TEXT NOT NULL, sentiment TEXT, CONSTRAINT sentiment_check CHECK (sentiment IN ('positive', 'negative', 'neutral')),