Sample Bookstore App: DB setup for Book Review Comments (#5896)

* first commit, made table and wrote docs

* removed book id

* reduced amt of sample data

* Update code-samples/eventing/bookstore-sample-app/db/sample.sql

Co-authored-by: Calum Murray <cmurray@redhat.com>

* Update code-samples/eventing/bookstore-sample-app/db/sample.sql

Co-authored-by: Calum Murray <cmurray@redhat.com>

* Update code-samples/eventing/bookstore-sample-app/db/sample.sql

Co-authored-by: Calum Murray <cmurray@redhat.com>

* Update code-samples/eventing/bookstore-sample-app/db/sample.sql

Co-authored-by: Calum Murray <cmurray@redhat.com>

---------

Co-authored-by: Calum Murray <cmurray@redhat.com>
This commit is contained in:
Scott Hirano 2024-03-08 14:32:08 -05:00 committed by GitHub
parent 46d0e55693
commit 03bf62be60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,26 @@
# 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')
## 2. Sample Data
### BookReviews Table
The sample rows inserted for the BookReviews table are shown below:
| 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 |

View File

@ -0,0 +1,13 @@
CREATE TABLE IF NOT EXISTS book_reviews(
id SERIAL PRIMARY KEY,
post_time timestamp NOT NULL,
content TEXT NOT NULL,
sentiment TEXT,
CONSTRAINT sentiment_check CHECK (sentiment IN ('positive', 'negative', 'neutral')),
);
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');